repo.maven.apache.org 的 Nexus 代理不起作用

Tyv*_*ain 3 apache nexus maven

我在 nexus 中为 apache 库创建了一个新闻代理 maven 2: 在此处输入图片说明

然后我改变了我的 pom.xml 如下:

<repositories>
    <repository>
        <id>maven-public</id>
        <url>http://nexus.unc.nc/repository/maven-public/</url>
    </repository>
    <repository>
        <id>maven-releases</id>
        <url>http://nexus.unc.nc/repository/maven-releases/</url>
    </repository>
    <repository>
        <id>maven-apache</id>
        <url>http://nexus.unc.nc/repository/maven-apache/</url>
    </repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)

但它仍然从互联网下载 apache lib:

[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ importparcoursup ---
Downloading from central: https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom
Downloaded from central: https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom (998 B at 2.0 kB/s)
Run Code Online (Sandbox Code Playgroud)

而其他库是从关系中获取的:

Downloading from maven-public: http://nexus.unc.nc/repository/maven-public/org/springframework/boot/spring-boot-starter-mail/2.0.6.RELEASE/spring-boot-starter-mail-2.0.6.RELEASE.pom
Run Code Online (Sandbox Code Playgroud)

有人可以在这里帮助我吗?

Ill*_*sil 7

这是因为central存储库的配置是从超级 POM继承的。您可以尝试按如下方式覆盖它:

<repository>
    <id>central</id>
    <url>http://nexus.unc.nc/repository/maven-apache/</url>
</repository>
Run Code Online (Sandbox Code Playgroud)

或者 - 这是推荐的解决方案 - 将镜像定义放入settings.xml

<settings>
  ...
  <mirrors>
    <mirror>
      <id>company-central</id>
      <name>Company Central</name>
      <url>http://nexus.unc.nc/repository/maven-apache/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>
Run Code Online (Sandbox Code Playgroud)