标签 Maven 下的文章

Maven duplicate declaration of version

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for cn.com.etianan.ebusiness:online:war:0.0.2-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:basicBizInfo:jar -> duplicate declaration of version (?) @ line 197, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:claimService:jar -> duplicate declaration of version (?) @ line 250, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:productDirectory:jar -> duplicate declaration of version (?) @ line 254, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:permission:jar -> duplicate declaration of version (?) @ line 279, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cn.com.etianan.ebusiness:payment:jar -> duplicate declaration of version (?) @ line 287, column 15
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.mortbay.jetty:maven-jetty-plugin @ line 360, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building online 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://localhost:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] Downloading: http://maven-beabuild-plugin.googlecode.com/svn/maven2/releases/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:10.535s
[INFO] Finished at: Tue Dec 31 11:21:09 GMT+08:00 2013
[INFO] Final Memory: 2M/4M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to nexus (http://localhost:8081/nexus/content/groups/public): Connection to http://localhost:8081 refused: Connection refused: connect -> [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/PluginResolutionException

原因是因为出现了重复的dependency节点。删除重复节点,留下一个即可。

Classpath entry will not be exported

Classpath entry will not be exported or published. Runtime ClassNotFoundExceptions may result.

Eclipse出现大量这样的警告,都是Maven的依赖库jar报出来的。尝试Maven Update Project 之后问题解决。

Eclipse报错:Missing artifact com.adobe.xmp:xmpcore:jar:5.1.2

Eclipse报错:

Missing artifact com.adobe.xmp:xmpcore:jar:5.1.2

Project '???' is missing required library:'C:\Users\tun.m2\repository\antlr\antlr\2.7.2\antlr-2.7.2.jar'

这个是maven查找服务器上面的jar包的时候没有找到jar包报错。可能是我们maven项目配置文件pom.xml里面的distributionManagement -> repository 或者 snapshotRepository 下面的 url 指定的服务器地址无法访问。

也可能是maven全局配置settings.xml里面的localRepository指定的目录不存在,或许去掉localRepsotory,直接使用m2eclipse的默认目录c:\users\xxx.m2\repository。

也可能是eclipse 全局设置 Preferences -> Maven -> User settings里面没有指定我们自己的settings.xml造成。

参考Maven官网对于settings.xml的解释,默认mvn读取的是maven\conf\settings.xml文件。所以必须保证文件位置和名字正确。