我正在设置一个本地Nexus存储库,并试图说服我的本地Maven安装程序将该回购作为唯一的。Nexus有一个组maven-central定义(引用Nexus手册:) "...accesses the Central Repository,以前称为Maven Central“。并且还应该缓存下载的数据。
因此,我将本地Nexus输入到我的home.m2\settings.xml中,如下所示:
...
<profile>
<id>alwaysActiveProfile</id>
<repositories>
<repository>
<id>RepoSynoProxy</id>
<name>Nexus Repo on Synology NAS</name>
<url>http://192.168.1.15:8081/repository/maven-central/</url>
</repository>
</repositories>
</profile>
</profiles>
...
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
</activeProfiles>
...但出于某种奇怪的原因,当我运行Maven时,它开始从https://repo.maven.apache.org/maven2/下载所有内容,而不是从本地URL下载,正如我所期望的那样:
...
[INFO] Downloading from : http://192.168.1.15:8081/repository/maven-central/junit/junit/3.8.1/junit-3.8.1.pom
[INFO] Downloading from : https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom (998 B at 7.3 kB/s)
[INFO] Downloading from : http://192.168.1.15:8081/repository/maven-central/junit/junit/3.8.1/junit-3.8.1.jar
[INFO] Downloading from : https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar (121 kB at 1.4 MB/s)
...因此,我的问题:
首先:有谁知道,为什么http://192.168.1.15:8081/repository/maven-central/的请求.显然不起作用?我在这里使用的是刚下载并安装的Nexusv3.18.0。Maven-central代理已经预先定义好了,我没有配置任何特殊的代理。很明显,“开箱即用”是行不通的。
第二: Maven在哪里有URL https://repo.maven.apache.org/maven2/..。从这个意义上说,它是用来替代的?如果回购不起作用,那会被硬编码成Maven吗?你能抑制它,使它只访问在settings.xml中定义的回购吗?
发布于 2019-08-08 15:58:35
您需要在settings.xml中配置一个镜像,它将覆盖超级pom和其他pom文件中的存储库定义:https://help.sonatype.com/display/NXRM3/Maven+Repositories#MavenRepositories-ConfiguringApacheMaven。
https://stackoverflow.com/questions/57403097
复制相似问题