Search code examples
maven-3

Why "Blocked mirror for repositories" error though using HTTPS URL in maven settings.xml


my maven version is 3.8.5, and the following is mirrors config in maven settings.xml

<mirrors>
<mirror>
      <id>aliyun</id>
      <mirrorOf>*</mirrorOf>
      <name>aliyun</name>
      <url>https://maven.aliyun.com/nexus/content/groups/public/</url>
      <blocked>true</blocked>
    </mirror>
  </mirrors>

When blocked set false , mvn packge running ok, but it set true , then output following error

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 209, column 21
[ERROR] Non-resolvable import POM: Could not transfer artifact org.springframework.security:spring-security-bom:pom:5.6.3 from/to aliyun (https://maven.aliyun.com/nexus/content/groups/public/): Blocked mirror for repositories: [central (https://repo.maven.apache.org/maven2, default, releases)] @ org.springframework.boot:spring-boot-dependencies:2.6.7, /data/mvn/repository/org/springframework/boot/spring-boot-dependencies/2.6.7/spring-boot-dependencies-2.6.7.pom, line 2751, column 19
[ERROR] Non-resolvable import POM: Could not transfer artifact org.springframework.session:spring-session-bom:pom:2021.1.3 from/to aliyun (https://maven.aliyun.com/nexus/content/groups/public/): Blocked mirror for repositories: [central (https://repo.maven.apache.org/maven2, default, releases)] @ org.springframework.boot:spring-boot-dependencies:2.6.7, /data/mvn/repository/org/springframework/boot/spring-boot-dependencies/2.6.7/spring-boot-dependencies-2.6.7.pom, line 2758, column 19
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.adwetec:adwetec:1.0 (/data/adwetec-user/adwetec-idm/pom.xml) has 2 errors
[ERROR]     Non-resolvable import POM: Could not transfer artifact org.springframework.security:spring-security-bom:pom:5.6.3 from/to aliyun (https://maven.aliyun.com/nexus/content/groups/public/): Blocked mirror for repositories: [central (https://repo.maven.apache.org/maven2, default, releases)] @ org.springframework.boot:spring-boot-dependencies:2.6.7, /data/mvn/repository/org/springframework/boot/spring-boot-dependencies/2.6.7/spring-boot-dependencies-2.6.7.pom, line 2751, column 19 -> [Help 2]
[ERROR]     Non-resolvable import POM: Could not transfer artifact org.springframework.session:spring-session-bom:pom:2021.1.3 from/to aliyun (https://maven.aliyun.com/nexus/content/groups/public/): Blocked mirror for repositories: [central (https://repo.maven.apache.org/maven2, default, releases)] @ org.springframework.boot:spring-boot-dependencies:2.6.7, /data/mvn/repository/org/springframework/boot/spring-boot-dependencies/2.6.7/spring-boot-dependencies-2.6.7.pom, line 2758, column 19 -> [Help 2]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

WHY?How to set it ?


Solution

  • You have to configure the central access in your settings.xml correctly like this:

     <profiles>
        <profile>
          <id>nexus</id>
          <!--Enable snapshots for the built in central repo to direct -->
          <!--all requests to nexus via the mirror -->
          <repositories>
            <repository>
              <id>central</id>
              <url>https://central</url>
              <releases>
                <enabled>true</enabled>
                <checksumPolicy>fail</checksumPolicy>
              </releases>
              <snapshots>
                <enabled>true</enabled>
                <checksumPolicy>fail</checksumPolicy>
              </snapshots>
            </repository>
          </repositories>
          <pluginRepositories>
            <pluginRepository>
              <id>central</id>
              <url>https://central</url>
              <releases>
                <enabled>true</enabled>
                <checksumPolicy>fail</checksumPolicy>
              </releases>
              <snapshots>
                <enabled>true</enabled>
                <checksumPolicy>fail</checksumPolicy>
              </snapshots>
            </pluginRepository>
          </pluginRepositories>
        </profile>
       <activeProfiles>
        <activeProfile>nexus</activeProfile>
       </activeProfiles>