【问题标题】:how to deploy my artifact on to my nexus?如何将我的工件部署到我的关系上?
【发布时间】:2012-01-14 21:17:29
【问题描述】:

我使用 nexus 开源作为 Maven 3.0.3 的存储库管理器

Maven 能够创建工件 *.jar。

现在,我想知道如何将生成的工件 *.jar 推送到 nexus 存储库管理器,以便其他依赖模块可以从中提取。

我提到了这个guide

settings.xml,我有

    <server>     
            <id>nexus-site</id>
            <username>admin</username>
            <password>xxxx</password>
    </server>

失败了。

如何从 mvn 命令调用我的部署或如何将我的工件部署到我的 nexus 上?

【问题讨论】:

  • It fails 是什么意思?你尝试了什么命令,你得到了什么错误?
  • 指南的链接说将 repo 用户名/密码放在 ~/.m2/repository/settings.xml 中。我发现我必须在 ~/.m2 中有 settings.xml 才能让它工作。

标签: maven maven-2 maven-3 nexus


【解决方案1】:

如果要将其添加到快照存储库中,则需要在 pom.xml 中进行以下配置

<distributionManagement>
    <repository>
         <id>nexus-site</id>
         <name>MyCo Internal Repository</name>
         <url>http://Nexus url</url>
    </repository>
    <snapshotRepository>
         <id>nexus-site</id>
         <name>Your Snapshot Repository</name>
         <url>http://Nexus url</url>
    </snapshotRepository>
</distributionManagement>

【讨论】:

    【解决方案2】:

    还应指定存储库元素。 片段:pom.xml

    <distributionManagement>
        <repository>
          <id>internal.repo</id>
          <name>MyCo Internal Repository</name>
          <url>http://Nexus url</url>
        </repository>
      </distributionManagement>
    

    【讨论】:

      【解决方案3】:

      有两种方法可以做到这一点。

      首先是通过 Nexus Web 界面进行,只需上传带有必要项目信息(groupId、artifactId、版本)的工件

      另一个使用mvn deploy。您需要设置要上传到的存储库的分发管理,以及要进行身份验证的用户。

      如果您要定期进行部署,强烈建议使用第二种方法。它是自动化的,您可以利用其他 Maven 命令,例如 mvn release

      【讨论】:

      • 我收到一个错误 ERROR] 无法在项目 mdaq 上执行目标 org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-cli):部署失败:存储库元素是未在 distributionManagement 元素内的 POM 或 -DaltDeploymentRepository=id::layout::url 参数中指定 -> [Help 1]
      【解决方案4】:

      试试吧

         mvn deploy
      

      这会将您的工件部署到 nexus 存储库管理器。

      您是否配置了分发管理部分?

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      • 2020-10-18
      • 1970-01-01
      • 2013-05-17
      相关资源
      最近更新 更多