我有一个构建服务器,它将所有maven依赖项查找镜像到本地sonatype nexus。最近Maven没有查找依赖项,我不明白为什么。
在构建服务器的.m2 / settings.xml中,我有以下镜像设置。
<mirrors>
<mirror>
<id>nexus</id>
<url>http://my-host/nexus/content/groups/public</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
使用-X开关构建项目我得到以下输出
[DEBUG] === PROJECT BUILD PLAN ================================================
[DEBUG] Project: my.group:my.artifact:1.4.2-SNAPSHOT
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): [compile, runtime, test]
[DEBUG] Repositories (dependencies): [nexus (http://my-host/nexus/content/groups/public, releases)]
[DEBUG] Repositories (plugins) : [nexus (http://my-host/nexus/content/groups/public, releases)]
[DEBUG] =======================================================================
[DEBUG] Could not find metadata my.group:my.artifact-2:1.5.1-SNAPSHOT/maven-metadata.xml in local (/usr/local/jenkins/.m2/repository)
[DEBUG] Could not find metadata my.group:my.artifact-2:1.5.1-SNAPSHOT/maven-metadata.xml in local (/usr/local/jenkins/.m2/repository)
[WARNING] The POM for my.group:my.artifact-2:jar:1.5.1-SNAPSHOT is missing, no dependency information available
[DEBUG] my.group:my.artifact:jar:1.4.2-SNAPSHOT
[DEBUG] my.group:yyyyy:jar:1.3.0-SNAPSHOT:compile
[DEBUG] my.group:xxxx:jar:1.3.0-SNAPSHOT:compile
[DEBUG] com.oracle:oracle-driver:jar:11.1:compile
[DEBUG] my.group:my.artifact-2:jar:1.5.1-SNAPSHOT:compile
[DEBUG] my.group:zzzzz:jar:1.0.2-SNAPSHOT:compile
[DEBUG] javax.servlet:servlet-api:jar:2.3:compile
[DEBUG] taglibs:standard:jar:1.1.2:compile
[DEBUG] log4j:log4j:jar:1.2.14:compile
[DEBUG] org.mockito:mockito-all:jar:1.9.5:test
[DEBUG] org.hamcrest:hamcrest-all:jar:1.3:test
[DEBUG] junit:junit:jar:4.10:test
[DEBUG] org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
浏览Nexus界面我可以在那里看到my.group:my.artifact-2:1.5.1-SNAPSHOT工件。在构建服务器中,文件夹/repository/my.group/my.artifact不存在。
答案 0 :(得分:1)
解决方案是将<repositories>
标记添加到pom
<repositories>
<repository>
<id>nexus</id>
<name>Repositório Central</name>
<url>http://my-host/nexus/content/repositories</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
答案 1 :(得分:0)
如果不修改任何pom.xml
,您可以在构建服务器.m2/settings.xml
中添加以下内容:
<profile><id>alwaysactive</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository><id>unused</id><url>unused</url></repository>
</repositories>
</profile>
这告诉maven: