【问题标题】:Configuring Multiple Maven Repositories配置多个 Maven 存储库
【发布时间】:2023-03-10 04:42:01
【问题描述】:

我有一个使用 maven 和 IntelliJ IDEA Ultimate Edition(主要用于 Java 项目的构建自动化工具)的 SpringBoot 项目 我有这个用于 maven 的 settings.xml,但是当我执行 mvn -U clean install 时,只会去第一个存储库找到文件

<?xml version="1.0" encoding="UTF-8"?>


<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <localRepository>C:/Users/sandro/.m2</localRepository>


  <pluginGroups>
  </pluginGroups>
  <proxies>
  </proxies>
  <servers>
  </servers>
  <mirrors>
    <mirror>
      <id>TeamNexus1</id>
      <mirrorOf>*</mirrorOf>
      <name>TeamNexus1</name>          
      <url>http://benficiones.com:8081/nexus/content/groups/public/</url>          
    </mirror>
    <mirror>
      <id>TeamNexus2</id>
      <mirrorOf>*</mirrorOf>
      <name>TeamNexus2</name>    
      <url>http://benficiones2.com:8081/nexus/content/groups/public/</url>
    </mirror>
  </mirrors>
  <profiles>
  <profile>
     <id>p1</id>
     <repositories>     
        <repository>
              <id>TeamNexus1</id>
            <name>TeamNexus1</name>      
            <url>http://benficiones.com:8081/nexus/content/groups/public/</url>      
            <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
            <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
        </repository>
        <repository>
            <id>TeamNexus2</id>
            <name>TeamNexus2</name>   
                   <url>http://benficiones2.com:8081/nexus/content/groups/public/</url>
             <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
             <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
        </repository>
  </repositories>
</profile>
  </profiles>
  <activeProfiles>
   <activeProfile>p1</activeProfile>
 </activeProfiles>
</settings>

【问题讨论】:

    标签: maven intellij-idea maven-2 maven-3 nexus


    【解决方案1】:

    您定义了 TeamNexus1 和 &lt;mirrorOf&gt; 一切。这意味着任何请求,无论他们去什么存储库,都会被重定向到 TeamNexus1。

    这可能不是你想要的。

    如果您想使用两个存储库除了 MavenCentral(这是隐式配置的),您可以删除整个&lt;mirrors&gt; 部分。

    【讨论】:

    • 使用建议的解决方案我有这个错误:无法读取 org.jacoco:jacoco-maven-plugin:jar:0.8.0 的工件描述符:无法传输工件 org.jacoco:jacoco-maven -plugin:pom:0.8.0 from/to central (repo.maven.apache.org/maven2):连接到 repo.maven.apache.org:443 [repo.maven.apache.org/151.101.36.215] 失败:连接超时:连接
    • 那么您可能无法直接连接到 MavenCentral。工件是否在 TeamNexus 存储库之一中?
    • 确实是这样
    • 然后只删除第二个镜像,第一个,写&lt;mirrorOf&gt;*,!TeamNexus2&lt;/mirrorOf&gt;
    • 上一条评论是最好的方法。如果您完全删除了 mirrors 部分,那么 Maven 将开始使用 pom 文件中的存储库定义,这将导致问题。使用“*,!TeamNexus2”。
    猜你喜欢
    • 2012-09-16
    • 2018-01-12
    • 1970-01-01
    • 1970-01-01
    • 2015-04-24
    • 2016-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多