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

上一篇 / 下一篇  2017-09-15 14:44:34 / 个人分类: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>

 
  


 

TAG:

 

评分:0

我来说两句

Open Toolbar