有一个项目myProject有两个模块,moduleB依赖于moduleA。 moduleA构建成功并部署在nexus上,但是当您尝试部署moduleB时,会出现以下错误:
[ERROR] Failed to execute goal on project moduleB:
Could not resolve dependencies for project groupId:moduleB:jar:1.0-SNAPSHOT
Failed to collect dependencies at groupId:moduleA:jar:1.0-SNAPSHOT:
Failed to read artifact descriptor for groupId:moduleA:jar:1.0-SNAPSHOT:
Could not find artifact groupId:myProject:pom:1.0-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:
Failed to execute goal on project moduleB:
Could not resolve dependencies for project groupId:moduleB:jar:1.0-SNAPSHOT:
Failed to collect dependencies at groupId:moduleA:jar:1.0-SNAPSHOT
或者有时这个:
[ERROR] Failed to execute goal on project moduleB:
Could not resolve dependencies for project groupId:moduleB:jar:1.0-SNAPSHOT
Failed to collect dependencies at groupId:moduleA:jar:1.0-SNAPSHOT:
Failed to read artifact descriptor for groupId:moduleA:jar:1.0-SNAPSHOT:
Failure to find groupId:myProject:pom:360
in http://lonrs07557:8081/nexus/content/groups/public/ was cached in the local repository,
resolution will not be reattempted until the update interval
of myProject_maven_repo has elapsed or updates are forced.
我四处寻找解决方案,但每次都会遇到不同的错误,而且它会变得混乱。我尝试过干净的U,依赖树,有效的pom等等(不成功)。我的maven repo设置正确:
<repositories>
<repository>
<id>nexus</id>
<name>nexus repository</name>
<url>http://lonrs07557:8081/nexus/content/groups/repo</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
[...]
<distributionManagement>
<site>
<id>lonrs07557-docs</id>
<name>Documentation Repository</name>
<url>scp://lonrs07557:9999/content/maven/site-documentation</url>
</site>
<repository>
<id>lonrs07557-releases</id>
<name>Release Repository</name>
<url> dav:http://lonrs07557:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>lonrs07557-snapshots</id>
<name>Snapshot Repository</name>
<url>dav:http://lonrs07557:8081/nexus/content/repositories/snapshots</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
其中一个问题是正在寻找旧版本的主pom(虽然旧版本没有在任何地方引用)。
还有一个警告说pom丢失了,但我可以在nexus中看到它。
[WARNING] The POM for groupId:log-util:jar:1.0-SNAPSHOT is missing,
no dependency information available
此外,当我在本地构建时,一切都很成功,当我稍后通过TeamCity进行此操作时,它未能完成上述操作,所以在我努力在本地重现问题时,我删除了我当地的maven repo并且它被迫创建一个新的,导致相同的错误。然后我通过首先构建moduleA然后再构建moduleB来解决这个问题。但是,当我通过TeamCity代理程序执行此操作时,我无法使用相同的解决方法。
我运行它(在本地和在TeamCity中)的方式是:
mvn clean deploy -f moduleB/pom.xml -U -X
的settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>c:/maven/repository</localRepository>
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
<pluginGroup>com.totsp.gwt</pluginGroup>
</pluginGroups>
<servers>
<server>
<id>lonrs07563-docs</id>
<username>XXXXX</username>
<password>XXXXX</password>
<configuration>
<knownHostsProvider
implementation="org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider">
<hostKeyChecking>no</hostKeyChecking>
</knownHostsProvider>
</configuration>
</server>
<server>
<id>lonrs07557-releases</id>
<username>XXXXX</username>
<password>XXXXX</password>
</server>
<server>
<id>lonrs07557-snapshots</id>
<username>XXXXX</username>
<password>XXXXX</password>
</server>
</servers>
<mirrors>
<mirror>
<id>myProject_maven_repo</id>
<mirrorOf>*</mirrorOf>
<url>http://lonrs07557:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<clusterport>${env.MYPROJECT_CLUSTER_PORT}</clusterport>
<clusteraddress>${env.MYPROJECT_CLUSTER_ADDRESS}</clusteraddress>
<hostname>${env.hostname}</hostname>
</properties>
</profile>
</profiles>
</settings>