简体   繁体   English

Maven-Artifactory中的多个私人存储库

[英]Maven - multiple private repositories in Artifactory

I have already working project which downloading .jar bundles from private repositories in Artifactory, and I'm trying to add another repository from which maven will donwload regular maven dependencies. 我已经有一个项目正在从Artifactory的私有存储库中下载.jar捆绑软件,并且我正在尝试添加另一个Maven将从其下载常规Maven依赖项的存储库。

I've added repository tag to my parent's POM 我已将存储库标签添加到我父母的POM中

    <repository>
      <id>MyId-1</id>
      <url>https://artifactory-url/artifactory/Myfolder-1/</url>
      <layout>default</layout>
    </repository>

to settings.xml 到settings.xml

    <server>
      <id>MyId-1</id>
      <username>{username}</username>
      <password>{password}</password>
    </server>

But it still not found my expected dependencies. 但是仍然找不到我期望的依赖项。

Also in my settings.xml has defined proxy mirror to Artifactory: 同样在我的settings.xml中,已经定义了Artifactory的代理镜像:

  <mirrors>
    <mirror>
      <id>MyId-2</id>
      <mirrorOf>central</mirrorOf>
      <name>MyName-2</name>
      <url>https://artifactory-url/artifactory/Myfolder-2/</url>
    </mirror>
  </mirrors>

And when i change mirror's URL to my expected URL: 当我将镜像的URL更改为预期的URL时:

https://artifactory-url/artifactory/Myfolder-1/

Maven successfully downloading my expected dependencies, but doesn't download all others jars. Maven成功下载了我期望的依赖项,但没有下载所有其他jar。

I also have tried add another one mirror to my settings.xml, and my mirrors tag looks like: 我还尝试将另一个镜像添加到我的settings.xml中,并且我的mirrors标签看起来像:

  <mirrors>
    <mirror>
      <id>MyId-2</id>
      <mirrorOf>central</mirrorOf>
      <name>MyName-2</name>
      <url>https://artifactory-url/artifactory/Myfolder-2/</url>
    </mirror>
    <mirror>
      <id>MyId-1</id>
      <mirrorOf>*</mirrorOf>
      <name>MyName-1</name>
      <url>https://artifactory-url/artifactory/Myfolder-1/</url>
    </mirror>
  </mirrors>

But maven ignores it and I'm getting error when trying mvn install: 但是maven忽略了它,尝试进行mvn install时出现错误:

Could not find artifact {my-artifact}:pom:{version} in artifactory (https://artifactory-url/artifactory/Myfolder-2/)
The POM for {my-artifact}:jar:{version} is missing, no dependency information available

The best practice for using more than one repository is to configure a virtual repository in Artifactory. 使用多个存储库的最佳实践是在Artifactory中配置虚拟存储库。 Then you can aggregate all of your remote and local repositories inside this virtual repository and point your Maven "settings.xml" to this one virtual repository. 然后,您可以在此虚拟存储库中聚合所有远程和本地存储库,并将Maven“ settings.xml”指向该虚拟存储库。 All of your dependencies and jars will be able to be downloaded from there. 您可以从此处下载所有依赖项和jar。 For more information about virtual repositories visit JFrog's wiki page here . 有关虚拟存储库详细信息,请访问JFrog的wiki页面在这里

Seems like mirror tag messed everything up. 好像镜像标签弄乱了一切。 Resolved this : Removed mirroring central, and added to active profile both folders with jars, so now my repositories tag in settings.xml is : 解决此问题的方法:删除了中央镜像,并将两个带有jar的文件夹添加到活动配置文件中,所以现在我在settings.xml中的存储库标记为:

    <repository>
        <id>MyId-1</id>
        <url>https://artifactory-url/artifactory/Myfolder-1/</url>
    </repository>
    <repository>
          <id>central</id>
          <url> https://artifactory-url/artifactory/Myfolder-2/ </url>
    <repository>


声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM