我在将我的工件部署到 nexus 时遇到问题。我正在使用 sonatype 的 maven 和 nexus-staging-maven-plugin。我的项目结构是:父 A 有 2 个子模块 B 和 C。在 BI 的 pom.xml 中声明了如下插件(当然还有存储库等):
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<nexusUrl>http://nexus.intranet:8081/repository/myrepo/</nexusUrl>
<serverId>nexus</serverId>
<skipStaging>true</skipStaging>
</configuration>
</plugin>
我的工件正在正确部署到 nexus 文件夹 com/myorg/B/1.1.5/ 并且存在 jar 和 B 的 pom.xml 和 sha 文件。问题是,当我添加到另一个项目依赖项 B 时,该项目想在关系 A(B 的父 pom)中找到。我也应该将父 pom.xml 部署到我的 nexus 吗?我应该如何在 B pom.xml 中配置我的插件以正确执行它?
你还必须始终部署所有父 POM,因为没有父 POM,Maven 无法读取 POM。
因此,在多模块项目中,你应该将包括父模块在内的所有模块部署到同一位置。