Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6879

When the repo with the id of central is configured in settings.xml and the scope = import dependency is included in the project of the project, the central repo has a problem

    XMLWordPrintableJSON

Details

    • Patch, Important

    Description

      When the repo with the id of central is configured in settings.xml and the scope = import dependency is included in the project of the project, the central repo has a problem

       

      settings.xml配置如下:

      <profile>  
                  <id>nexusRep</id>  
                  <repositories>  
                      <repository>  
                          <id>nexus</id>  
                          <name>Nexus Repository</name>  
                          <url>https://repo.spring.io/libs-release1</url>  
                          <releases><enabled>true</enabled></releases>  
                          <snapshots><enabled>true</enabled></snapshots>  
                      </repository>  
                  </repositories>  
                   <pluginRepositories>  
                      <pluginRepository>  
                          <id>nexus</id>  
                          <name>Nexus pluginRepository</name>  
                          <url>https://repo.spring.io/libs-release1</url>  
                          <releases><enabled>true</enabled></releases>  
                          <snapshots><enabled>true</enabled></snapshots>  
                      </pluginRepository>  
                  </pluginRepositories>  
              </profile>    
              <profile>  
                  <id>central</id>  
                  <repositories>  
                      <repository>  
                          <id>central</id>  
                          <name>Nexus Repository</name>  
                          <url>https://repo.spring.io/libs-release</url>  
                          <releases><enabled>true</enabled></releases>  
                          <snapshots><enabled>true</enabled></snapshots>  
                      </repository>  
                  </repositories>  
                   <pluginRepositories>  
                      <pluginRepository>  
                          <id>central</id>  
                          <name>Nexus pluginRepository</name>  
                          <url>https://repo.spring.io/libs-release</url>  
                          <releases><enabled>true</enabled></releases>  
                          <snapshots><enabled>true</enabled></snapshots>  
                      </pluginRepository>  
                  </pluginRepositories>  
              </profile>  
            
        </profiles>
      <!-- activeProfiles
         | List of profiles that are active for all builds.
         |
        <activeProfiles>
          <activeProfile>alwaysActiveProfile</activeProfile>
          <activeProfile>anotherAlwaysActiveProfile</activeProfile>
        </activeProfiles>
        -->
        <activeProfiles>
         <activeProfile>nexusRep</activeProfile>
         <activeProfile>central</activeProfile>
        </activeProfiles>
      
      

       

      project pom.xml:

      //代码占位符
      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <parent>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-parent</artifactId>
              <version>2.2.5.RELEASE</version>
              <relativePath/> <!-- lookup parent from repository -->
          </parent>
          <groupId>com.example</groupId>
          <artifactId>demo</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <name>demo</name>
          <description>Demo project for Spring Boot</description>
      
          <properties>
              <java.version>1.8</java.version>
              <spring-cloud-dependencies.version>Angel.SR6</spring-cloud-dependencies.version>
          </properties>
      
          <dependencies>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-web</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.cloud</groupId>
                  <artifactId>spring-cloud-dependencies</artifactId>
                  <version>${spring-cloud-dependencies.version}</version>
                  <type>pom</type>
                  <scope>import</scope>
              </dependency>
              <dependency>
                  <groupId>org.projectlombok</groupId>
                  <artifactId>lombok</artifactId>
                  <scope>compile</scope>
                  <optional>true</optional>
              </dependency>
      
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-test</artifactId>
                  <scope>test</scope>
                  <exclusions>
                      <exclusion>
                          <groupId>org.junit.vintage</groupId>
                          <artifactId>junit-vintage-engine</artifactId>
                      </exclusion>
                  </exclusions>
              </dependency>
          </dependencies>
      
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.springframework.boot</groupId>
                      <artifactId>spring-boot-maven-plugin</artifactId>
                  </plugin>
              </plugins>
          </build>
      
          <repositories>
              <repository>
                  <id>test</id>
                  <name>repo</name>
                  <releases>
                      <enabled>true</enabled>
                  </releases>
                  <snapshots>
                      <enabled>true</enabled>
                  </snapshots>
                  <url>https://repo.spring.io/libs-release</url>
              </repository>
          </repositories>
      
      </project>
      
      

      The theoretical maven remote repository priority is:

      However, when resolving a scope = import dependency, such as:

      The warehouse priority will become as shown in the figure below:

      Found that the central repository was reset to the default,  and all dependent downloads will become this repo priority in the future.

      When resolving scope = import dependencies, this place will cause the resolving repo to become the default central:

      Finally at this place, the default modelResoler repo will be replaced with the default central:

      Attachments

        1. image-2020-03-24-22-01-04-185.png
          325 kB
          wuzishu
        2. image-2020-03-24-22-00-08-867.png
          100 kB
          wuzishu
        3. image-2020-03-24-21-58-35-400.png
          84 kB
          wuzishu
        4. image-2020-03-24-21-57-58-635.png
          354 kB
          wuzishu
        5. image-2020-03-24-21-49-31-997.png
          59 kB
          wuzishu
        6. image-2020-03-24-21-47-50-561.png
          76 kB
          wuzishu
        7. image-2020-03-24-21-39-54-127.png
          419 kB
          wuzishu

        Activity

          People

            Unassigned Unassigned
            idefav wuzishu
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: