Maven 3.8.1 报错 Blocked mirror for repositories

报错内容如下:

[ERROR] Failed to execute goal com.github.davidmoten:jax-maven-plugin:0.1.6:xjc (default) on project oozie-fluent-job-api: Execution default of goal com.github.davidmoten:jax-maven-plugin:0.1.6:xjc failed: Plugin com.github.davidmoten:jax-maven-plugin:0.1.6 or one of its dependencies could not be resolved: Failed to collect dependencies at com.github.davidmoten:jax-maven-plugin:jar:0.1.6 -> com.github.davidmoten:jax-maven-plugin-core:jar:0.1.6 -> com.sun.xml.ws:jaxws-tools:jar:2.3.1 -> com.sun.xml.ws:jaxws-rt:jar:2.3.1 -> com.sun.xml.ws:policy:jar:2.7.5 -> org.glassfish.jaxb:txw2:jar:2.4.0-b180608.0325: Failed to read artifact descriptor for org.glassfish.jaxb:txw2:jar:2.4.0-b180608.0325: Could not transfer artifact org.glassfish.jaxb:txw2:pom:2.4.0-b180608.0325 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [releases.java.net (http://maven.java.net/content/repositories/releases/, default, releases+snapshots), jvnet-nexus-staging (http://maven.java.net/content/repositories/staging/, default, releases+snapshots), eclipse (http://download.eclipse.org/rt/eclipselink/maven.repo, default, releases+snapshots), jvnet-nexus-snapshots (http://maven.java.net/content/repositories/snapshots/, default, snapshots)] -> [Help 1]

官方解决方案:

Maven – Release Notes – Maven 3.8.1 (apache.org)

图片.png

修复方案:

  • 更新依赖版本,替换http为https。

  • 保持当前依赖,通过 define a mirror in your settings来解决。

实践

在 home 目录下的 .m2/ 目录创建 settings.xml 文件,如下:

[root@localhost .m2]# pwd
/root/.m2
[root@localhost .m2]# ls
repository  settings.xml

settings.xml 全文如下:



    
        
        
          mirror-release.java.net
          mirror java.net release repository
          https://maven.java.net/content/repositories/releases/
          releases.java.net
        
        
          mirror-jvnet-nexus-staging
          mirror jvnet-nexus-staging repository
          https://maven.java.net/content/repositories/staging/
          jvnet-nexus-staging
        
        
          mirror-eclipse
          mirror eclipse repository
          https://download.eclipse.org/rt/eclipselink/maven.repo
          eclipse
        
        
          mirror-jvnet-nexus-snapshots
          mirror jvnet-nexus-snapshots repository
          https://maven.java.net/content/repositories/snapshots/
          jvnet-nexus-snapshots
        
    

通过命令 mvn help:effective-settings 检查当前settings

[root@localhost .m2]# mvn help:effective-settings
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-help-plugin:3.2.0:effective-settings (default-cli) @ standalone-pom ---
[INFO] 
Effective user-specific configuration settings:














  /root/.m2/repository
  
    
      releases.java.net
      mirror java.net release repository
      https://maven.java.net/content/repositories/releases/
      mirror-release.java.net
    
    
      jvnet-nexus-staging
      mirror jvnet-nexus-staging repository
      https://maven.java.net/content/repositories/staging/
      mirror-jvnet-nexus-staging
    
    
      eclipse
      mirror eclipse repository
      https://download.eclipse.org/rt/eclipselink/maven.repo
      mirror-eclipse
    
    
      jvnet-nexus-snapshots
      mirror jvnet-nexus-snapshots repository
      https://maven.java.net/content/repositories/snapshots/
      mirror-jvnet-nexus-snapshots
    
    
      external:http:*
      Pseudo repository to mirror external repositories initially using HTTP.
      http://0.0.0.0/
      true
      maven-default-http-blocker
    
  
  
    org.apache.maven.plugins
    org.codehaus.mojo
  



[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.755 s
[INFO] Finished at: 2021-06-10T16:21:52+08:00
[INFO] ------------------------------------------------------------------------

你可能感兴趣的:(Maven 3.8.1 报错 Blocked mirror for repositories)