Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.6.2
-
None
-
Mac,maven 3.6.2
-
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: