maven 手动添加jar包到本地仓库

在Jenkins中构建项目,遇到maven缺少插件的问题:

[ERROR] Failed to execute goal on project mianshi-service: Could not resolve dependencies for project com.shiku:mianshi-service:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.xiaomi.push:mipush-sdk-server:jar:2.2.18, org.json:json-simple:jar:1.1.1: Could not find artifact com.xiaomi.push:mipush-sdk-server:jar:2.2.18 in spring-snapshots (http://repo.spring.io/snapshot) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :mianshi-servi

方法一:

有时maven库中的插件不好拉取,如网速不好或特殊的项目依赖包等因素,可以将需要的jar包直接添加到本地maven库中,减少很多麻烦。

1、准备好需要的jar包,放置在方便的路径下,并进入到这个目录

2、执行命令:mvn install:install-file   -Dfile=json-simple-1.1.1.jar  -DgroupId=org.json  -DartifactId=json-simple -Dversion=1.1.1  -Dpackaging=jar

需要什么包就改成相应的名字,执行后将出现下面提示,之后构建就不会出现maven缺包的情况:

 

方法二:

,我今天遇到这个情况,方法一不起效,在本机上直接执行构建命令就可以构建成功,但是在Jenkins上构建,还是报上面的错误,检查了Jenkins的配置 ,项目配置,没有发现任何问题,无奈之下,只有设置Jenkins的全局变量设置,将maven改成自动安装:系统管理-->全局工具配置-->maven

然后打开项目配置,在pre step中添加mvn的添加插件到仓库的命令,需要注意的是,要在服务器的相应目录中准备好jar包,配置保存后,构建项目就不会出现maven缺少包的问题了。

(我构建之前是将服务器上的maven卸载了的,Jenkins在构建项目时,会下载maven这个插件,然后在Jenkins的目录下保存maven的仓库,那卸不卸载本机的maven,看你自己的了)

 

转载于:https://www.cnblogs.com/Christine-ting/p/10497318.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值