【问题标题】:how to set pom.xml to download artifact from nexus remote repository如何设置 pom.xml 以从 nexus 远程存储库下载工件
【发布时间】:2014-10-18 05:27:27
【问题描述】:

我想在 maven 中使用我的本地存储库设置一个远程 nexus 存储库,当工件不在本地存储库中时,应该从我的远程存储库下载它并安装到本地存储库。如何设置?

【问题讨论】:

    标签: maven pom.xml nexus


    【解决方案1】:

    你必须在你的 pom 中添加一个存储库部分。

    这是一个例子:

    <repositories>
        <repository>
            <id>browserid-snapshots</id>
            <name>browserid-snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </repository>
    </repositories>
    

    取自这里https://github.com/user454322/browserid-verifier/blob/e7b81495882312c8cd9f1fb7e8313e239a6b3238/sample/pom.xml#L67-L73


    查看POM Reference 上的存储库部分了解更多信息。

    【讨论】:

    【解决方案2】:

    你可以在你的 POM 中定义你的远程仓库;但是,在大多数情况下,您将在所有项目中使用相同的远程存储库,因此您可以在 settings.xml 中设置它,而不是在所有 POM 中一遍又一遍地定义它 %MAVEN_HOME%/conf/settings.xml

        <profile>
          <repositories>
            <repository>
              <id>plt-release</id>
              <name>my-release</name>
              <url>http://<ip>:<port>/artifactory/release-local</url>
            </repository>
            <repository>
              <snapshots/>
              <id>plt-snapshot</id>
              <name>my-snapshot</name>
              <url>http://<ip>:<port>/artifactory/snapshot-local</url>
            </repository>
          </repositories>
          <id>artifactory</id>
        </profile>
    
      </profiles>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-13
      • 2019-05-12
      • 2021-11-21
      • 2016-05-22
      • 1970-01-01
      • 2022-08-05
      • 1970-01-01
      • 2021-03-08
      相关资源
      最近更新 更多