问题
I am in a closed network, do not have access to http://repo.maven.apache.org We set up a Nexus server and we download all of our .m2's on a publicly accessible computer, burn to disk, then upload to our Nexus server (inefficient but necessary)
Currently I am trying to set up the system to only use my nexus server, currently it tries to go to http://repo.maven.apache.org (assuming is set to false) If I have set to true, it does not even attempt to go to my private repo. Basically, I just need my Maven to only look at my nexus instance, not even attempt to go to http://repo.maven.apache.org
Here are portions of my settings.xml and pom.xml files:
<!-- Settings.xml in my .m2 directory -->
<offline>true</offline>
<servers>
<server>
<id>mynexus</id>
<username>xxx</username>
<password>xxx</username>
</server>
<server>
<id>mynexusplugins</id>
<username>xxx</username>
<password>xxx</username>
</server>
</servers>
<!-- pom.xml -->
<repositories>
<repository>
<id>mynexus</id>
<url>http://192.168.100.4:8081/....</url>
</repository>
</repository>
<pluginRepositories>
<pluginRepository>
<id>mynexusplugins</id>
<url>http://192.168.100.4:8081/....</url>
</pluginRepository>
</pluginRepository>
回答1:
Add your repository as mirror of all in the settings.xml, this way it won't look any other repo.
<mirrors>
<mirror>
<id>yourRepo</id>
<name>yourRepo name</name>
<url>your url</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
https://maven.apache.org/guides/mini/guide-mirror-settings.html
As a side note, If you set offline in maven(via command line or config) it will only use local m2 folder.
来源:https://stackoverflow.com/questions/49286208/private-maven-repository-in-closed-network