首页 > 解决方案 > 当它有父pom时如何正确地将工件部署到nexus?

问题描述

我在将我的工件部署到 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 时,该项目试图在 nexus A(B 的父 pom)中找到。我也应该将父 pom.xml 部署到我的关系吗?我应该如何在 B pom.xml 中配置我的插件才能正确执行?

标签: mavenpom.xmlnexussonatype

解决方案


我已经解决了我的问题。答案是肯定的——如果你想在某个地方使用子模块作为依赖项,你也需要在存储库中拥有它的父 pom。我通过从 sonatype 添加到我的父 pom 暂存插件来解决问题,以便也可以将父 pom 部署到 nexus。比构建成功,现在我可以使用我的子工件(在我的问题中名为 B)作为另一个项目的依赖项。


推荐阅读