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

用MAVEN自动化管理项目固然好,但是对于依赖问题是一个头痛的问题,特别对于newbaby,
当我们SVN检查项目会出现以下问题
[color=red]could not resolve artifact
Missing artifact org.apache.httpcomponents:fluent-hc:jar:4.3.6
Missing artifact com.jhlabs:imaging:jar:01012005[/color]
这些问题都是依赖包不能从仓库中,下载所致,这要归功于国家了,生在这个国家,做开发,悲哀,别悲伤,我们有解决办法:
一般
1.clean project
2.mvn clean
3.右击项目maven-》update project,并选择强制更新;


如果上面无法解决:
加仓库:


atlassian
atlassian
http://maven.jahia.org/maven2/


com.springsource.repository.maven.release
http://maven.springframework.org/release/
false


oracleReleases
Oracle Released Java Packages
http://download.oracle.com/maven


JBossRepo1
Jboss1
https://repository.jboss.org/nexus/content/groups/public-jboss/


JBossRepo
Jboss
https://repository.jboss.org/nexus/content/repositories/releases/


删除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

org.apache.httpcomponents
fluent-hc
provided
4.3.6

带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为环境标识

com.dameng
Dm7JdbcDriver
7.1.3.204
jdk16
test


下面一般是其他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

你可能感兴趣的:(Maven)