Maven项目中依赖的包无法从maven中央仓库下载怎么办

 Jenkins构建时提示找不到selenium-server-standalone.jar,由于项目中遇到这个问题,所以需要学习来解决一下当maven中央仓库中没有要用到的jar包时怎么解决?

   maven install可以实现将jar包手动安装到本地仓库,下面就总结下如何手动安装到maven本地仓库中。

  1.从网上下载jar包

   常用的做法是从百度搜索selenium-server-Standalone.jar,可以下载,网上有很多提供下载的方法

  2.将下载好的jar包放在本地磁盘,如D:\jar\路径下

  3.到maven中央仓库http://mvnrepository.com搜索selenium-server-standalone,然后选择对应版本,如2.46.0,打开后可以看到下面图上的依赖信息,groupId和artifactId的具体值可以,在pom.xml配置依赖包的时候也需要写这个值

      

   

  4.maven手动安装jar包的命令是:

   mvn install:install-file -Dfile=jar包放置的路径 -DgroupId=jar包的groupId -DartifactId=jar包的artifactId -Dversion=版本号 -Dpackaginig=jar

  

  在CMD窗口中输入mvn install命令:

  mvn install:install-file -Dfile=D:\jar\selenium-server-standalone.jar -DgroupId=org.seleniumhq.selenium -DartifactId=selenium-server-standalone -Dversion=2.46.0 -Dpackaging=jar
 运行后会有info显示安装路径

 

 然后安装好后,在Jenkins构建检查是否还是存在找不到这个jar包,构建后发现还是找不到,然后到Jenkins系统配置中去检查配置的maven 路径是不是default的,发现是配置不对,然后修改为default后,最后build成功。

还有一种直接引入的方式:在pom.xml引入:

<!--https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server-standalone-->
<dependency>
    <groupId>selenium</groupId>
    <artifactId>selenium-server-standalone</artifactId>
    <version>2.46.0</version>

    <systemPath>D:\jar\selenium-server-standalone.jar</systemPath>
</dependency>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值