`
Donald_Draper
  • 浏览: 980169 次
社区版块
存档分类
最新评论

Maven依赖包问题解决-could not resolve artifact/Missing artifact

阅读更多
用MAVEN自动化管理项目固然好,但是对于依赖问题是一个头痛的问题,特别对于newbaby,
当我们SVN检查项目会出现以下问题
could not resolve artifact
Missing artifact org.apache.httpcomponents:fluent-hc:jar:4.3.6
Missing artifact com.jhlabs:imaging:jar:01012005

这些问题都是依赖包不能从仓库中,下载所致,这要归功于国家了,生在这个国家,做开发,悲哀,别悲伤,我们有解决办法:
一般
1.clean project
2.mvn clean
3.右击项目maven-》update project,并选择强制更新;


如果上面无法解决:
加仓库:
<repositories>
	<repository>  
            <id>atlassian</id>  
            <name>atlassian</name>  
            <url>http://maven.jahia.org/maven2/</url>  
    	</repository> 
       <repository>  
          <id>com.springsource.repository.maven.release</id>  
          <url>http://maven.springframework.org/release/</url>  
          <snapshots><enabled>false</enabled></snapshots>  
       </repository>    
       <repository>  
          <id>oracleReleases</id>  
          <name>Oracle Released Java Packages</name>  
          <url>http://download.oracle.com/maven</url>  
        </repository>  
        <repository>  
            <id>JBossRepo1</id>   
            <name>Jboss1</name>   
            <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>   
        </repository>  
        <repository>  
            <id>JBossRepo</id>   
            <name>Jboss</name>   
            <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>   
        </repository>   
</repositories>

删除maven本地仓库依赖包对应的文件夹,maven-》update project

仍不能解决:
0.下载相应的jar包,手动安装
1.删除maven本地仓库依赖包对应的文件夹
2.先进入DOS,再进入jar所在的目录
3.执行命令
mvn install:install-file -Dfile=fluent-hc-4.3.6.jar -DgroupId=org.apache.httpcomponents -DartifactId=fluent-hc -Dversion=4.3.6 -Dpackaging=jar

参数说明:
-Dfile:jar包文件名带后缀
-DgroupId:组织id
-DartifactId:artifact Id
-Dversion:版本
-Dclassifier:环境一般为JDK
-Dpackaging:包类型
4.更新项目:maven-》update project
实例:
E:\mvnjar>mvn install:install-file -Dfile=imaging-01012005.jar -DgroupId=com.jhlabs -DartifactId=imaging -Dversion=01012005 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-pom ---
[INFO] Installing E:\mvnjar\imaging-01012005.jar to D:\.m2\repository\com\jhlabs\imaging\01012005\imaging-01012005.jar
[INFO] Installing C:\Users\donald\AppData\Local\Temp\mvninstall7803684983644843844.pom to D:\.m2\repository\com\jhlabs\imaging\01012005\imaging-01012005.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.591s
[INFO] Finished at: Tue Aug 16 16:47:39 CST 2016
[INFO] Final Memory: 2M/15M
[INFO] ---------------------------------------
对应POM
<dependency>
	<groupId>org.apache.httpcomponents</groupId>
	<artifactId>fluent-hc</artifactId>
	<scope>provided</scope>
	<version>4.3.6</version>
</dependency>

带classifier的依赖包
mvn install:install-file -Dfile=Dm7JdbcDriver-7.1.3.204-jdk16.jar -DgroupId=com.dameng -DartifactId=Dm7JdbcDriver -Dversion=7.1.3.204 -Dclassifier=jdk16 -Dpackaging=jar


对应的POM,-Dclassifier为环境标识
<dependency>
	<groupId>com.dameng</groupId>
	<artifactId>Dm7JdbcDriver</artifactId>
	<version>7.1.3.204</version>
	<classifier>jdk16</classifier>
	<scope>test</scope>
</dependency>


下面一般是其他jar的依赖包
mvn install:install-file -Dfile=httpcore-4.3.3.jar -DgroupId=org.apache.httpcomponents -DartifactId=httpcore -Dversion=4.3.3 -Dpackaging=jar


mvn install:install-file -Dfile=imaging-01012005.jar -DgroupId=com.jhlabs -DartifactId=imaging -Dversion=01012005 -Dpackaging=jar

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics