Maven如何手动添加依赖的jar文件到本地Maven仓库
发布日期:2021-06-30 11:36:03
浏览次数:2
分类:技术文章
本文共 2185 字,大约阅读时间需要 7 分钟。
Apache ,是一个软件(特别是软件)项目管理及自动构建工具,由Apache软件基金会所提供。基于项目对象模型(缩写:POM)概念,利用一个中央信息片断能管理一个项目的构建、报告和文档等步骤。曾是Jakarta项目的子项目,现为独立Apache项目。
大家肯定遇到过想在文件中加入自己开发的依赖包,这些包肯定是不是在仓库(http://repo1.maven.org/maven2/)的。那我们怎么将那些不存在Maven仓库中的包加入到本地的Maven库中呢?很简单。这里以IKAnalyzer.jar包为例进行讲解。 第一步:将IKAnalyzer.jar包存放在一个文件夹中,比如mylib文件夹 第二步:建一个IKAnalyzer.jar包相关的.xml文件,需要在pom.xml中定义其maven坐标及其相应的依赖代码即可,同样将pom文件存放在上述jar文件同一文件夹下,IKAnalyzer.jar坐标及依赖代码如下:<project xmlns= "" xmlns:xsi= "" |
xsi:schemaLocation= " " > |
<modelVersion> 4.0 . 0 </modelVersion> |
<groupId>org.wltea.ik-analyzer</groupId> |
<artifactId>ik-analyzer</artifactId> |
<version> 3.2 . 8 </version> |
<name>IK Analyzer 3 </name> |
<description>A dictionary and grammar-based Chinese segmenter.</description> |
<dependencies> |
<dependency> |
<groupId>org.apache.lucene</groupId> |
<artifactId>lucene-core</artifactId> |
<version> 3.0 . 3 </version> |
<optional> true </optional> |
</dependency> |
<dependency> |
<groupId>org.apache.solr</groupId> |
<artifactId>solr-core</artifactId> |
<version> 1.4 . 1 </version> |
<optional> true </optional> |
</dependency> |
<dependency> |
<groupId>junit</groupId> |
<artifactId>junit</artifactId> |
<version> 3.8 . 2 </version> |
<scope>test</scope> |
</dependency> |
<dependency> |
<groupId>org.apache.lucene</groupId> |
<artifactId>lucene-analyzers</artifactId> |
<version> 3.0 . 3 </version> |
<scope>test</scope> |
</dependency> |
<dependency> |
<groupId>org.apache.lucene</groupId> |
<artifactId>lucene-smartcn</artifactId> |
<version> 3.0 . 3 </version> |
<scope>test</scope> |
</dependency> |
</dependencies> |
</project> |
第三步:打开CMD,进入到mylib文件夹,运行下面命令
mvn install:install-file -Dfile=IKAnalyzer3. 2.8 .jar -DgroupId=org.wltea.ik-analyzer -DartifactId=ik-analyzer -Dversion= 3.2 . 8 -Dpackaging=jar |
这样你就可以将IKAnalyzer3.2.8.jar安装到您Maven本地的库文件夹相应目录中。你可以根据你需要安装包的实际情况修改上面的几个参数的设定值即可。之后你可以在pom.xml文件中通过以下依赖在项目中引入上述的包,如下:
<dependency> |
<groupId>org.wltea.ik-analyzer</groupId> |
<artifactId>ik-analyzer</artifactId> |
<version> 3.2 . 8 </version> |
</dependency> |
当然你也可以不将IKAnalyzer3.2.8.jar发布到您本地的Maven库中,而是通过下面配置引入,效果和上面的差不多:
<dependency> |
<groupId>org.wltea</groupId> |
<artifactId>IKAnalyzer</artifactId> |
<version> 3.2 . 8 </version> |
<systemPath>C:\Users\yangping\Desktop\a\IKAnalyzer3. 2.8 .jar</systemPath> |
</dependency> |
(完)
转载请注明: 转载自本文链接地址:
转载地址:https://iteblog.blog.csdn.net/article/details/9729621 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2024年04月04日 09时22分35秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
HDU 3788 ZOJ问题
2019-04-30
UVa 401 Palindromes(简单字符串)
2019-04-30
POJ1694 An Old Stone Game
2019-04-30
Codeforces Round #359 (Div. 2)
2019-04-30
HDU-2896 病毒侵袭 && HDU-3065 病毒侵袭持续中(AC自动机)
2019-04-30
Manacher算法(O(n)求得最长回文)
2019-04-30
POJ-3080 Blue Jeans(简单字符串)
2019-04-30
HDU-2594 Simpsons’ Hidden Talents(KMP)
2019-04-30
Codeforces Round #368 (Div. 2)
2019-04-30
HDU-1274 Hat’s Words(Trie树)
2019-04-30
POJ-2418 Hardwood Species(Trie树)(map)
2019-04-30
HDU-4300 Clairewd’s message + 4333(扩展KMP)
2019-04-30
HDU 1592 Half of and a Half(高精度)
2019-04-30
POJ-3304 Segments(计算几何)
2019-04-30
UVA-11538 Chess Queen(数学)
2019-04-30
UVA-11401 Triangle Counting(数学优化)
2019-04-30
UVA 11806 Cheerleaders(容斥原理)(组合数)
2019-04-30
Codeforces Round #369 (Div. 2)
2019-04-30
UVA 11426 GCD - Extreme (II)(欧拉函数)
2019-04-30
HDU-2838 Cow Sorting(树状数组)
2019-04-30