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

修复方案:

实践

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

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

settings.xml 全文如下:

<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
          xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
    <mirrors>
        <!--
        <mirror>
          <id></id>
          <name></name>
          <url></url>
          <mirrorOf></mirrorOf>
        </mirror>
        -->
        <mirror>
          <id>mirror-release.java.net</id>
          <name>mirror java.net release repository</name>
          <url>https://maven.java.net/content/repositories/releases/</url>
          <mirrorOf>releases.java.net</mirrorOf>
        </mirror>
        <mirror>
          <id>mirror-jvnet-nexus-staging</id>
          <name>mirror jvnet-nexus-staging repository</name>
          <url>https://maven.java.net/content/repositories/staging/</url>
          <mirrorOf>jvnet-nexus-staging</mirrorOf>
        </mirror>
        <mirror>
          <id>mirror-eclipse</id>
          <name>mirror eclipse repository</name>
          <url>https://download.eclipse.org/rt/eclipselink/maven.repo</url>
          <mirrorOf>eclipse</mirrorOf>
        </mirror>
        <mirror>
          <id>mirror-jvnet-nexus-snapshots</id>
          <name>mirror jvnet-nexus-snapshots repository</name>
          <url>https://maven.java.net/content/repositories/snapshots/</url>
          <mirrorOf>jvnet-nexus-snapshots</mirrorOf>
        </mirror>
    </mirrors>
</settings>

通过命令 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:

<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Generated by Maven Help Plugin on 2021-06-10T16:21:51+08:00            -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/                -->
<!--                                                                        -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Effective Settings for 'root' on 'localhost.localdomain'               -->
<!--                                                                        -->
<!-- ====================================================================== -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
  <localRepository>/root/.m2/repository</localRepository>
  <mirrors>
    <mirror>
      <mirrorOf>releases.java.net</mirrorOf>
      <name>mirror java.net release repository</name>
      <url>https://maven.java.net/content/repositories/releases/</url>
      <id>mirror-release.java.net</id>
    </mirror>
    <mirror>
      <mirrorOf>jvnet-nexus-staging</mirrorOf>
      <name>mirror jvnet-nexus-staging repository</name>
      <url>https://maven.java.net/content/repositories/staging/</url>
      <id>mirror-jvnet-nexus-staging</id>
    </mirror>
    <mirror>
      <mirrorOf>eclipse</mirrorOf>
      <name>mirror eclipse repository</name>
      <url>https://download.eclipse.org/rt/eclipselink/maven.repo</url>
      <id>mirror-eclipse</id>
    </mirror>
    <mirror>
      <mirrorOf>jvnet-nexus-snapshots</mirrorOf>
      <name>mirror jvnet-nexus-snapshots repository</name>
      <url>https://maven.java.net/content/repositories/snapshots/</url>
      <id>mirror-jvnet-nexus-snapshots</id>
    </mirror>
    <mirror>
      <mirrorOf>external:http:*</mirrorOf>
      <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
      <url>http://0.0.0.0/</url>
      <blocked>true</blocked>
      <id>maven-default-http-blocker</id>
    </mirror>
  </mirrors>
  <pluginGroups>
    <pluginGroup>org.apache.maven.plugins</pluginGroup>
    <pluginGroup>org.codehaus.mojo</pluginGroup>
  </pluginGroups>
</settings>


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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容