(1) configure the Nexus repository in POM
<Project>
...
<Repositories>
<Repository>
<ID> nexus </ID>
<Name> nexus </Name>
<URL> http: // localhost: 8081/nexus/content/groups/public/<URL>
<Release> <enabled> true </enabled> </release>
<Snapshots> <enabled> true> </enabled> </snapshots>
</Repository>
</Repositories>
<Pluginrepositories>
<Pluginrepository>
<ID> nexus </ID>
<Name> nexus </Name>
<URL> http: // localhost: 8081/nexus/content/groups/public/<URL>
<Release> <enabled> true </enabled> </release>
<Snapshots> <enabled> true> </enabled> </snapshots>
</Pluginrepository>
</Pluginrepositories>
...
</Project>
The above configuration is only valid for the current project. If you want all Maven projects on the local machine to use the mavne private server, you should configure it in setting. xml.
(2) configure the Nexus repository in setting. xml
<Settings>
...
<Profiles>
<Profile>
<ID> nexus </ID>
<Repositories>
<Repository>
<ID>Nexus</ID>
<Name> nexus </Name>
<URL> http: // localhost: 8081/nexus/content/groups/public/<URL>
<Release> <enabled> true </enabled> </release>
<Snapshots> <enabled> true> </enabled> </snapshots>
</Repository>
</Repositories>
<Pluginrepositories>
<Pluginrepository>
<ID> nexus </ID>
<Name> nexus </Name>
<URL> http: // localhost: 8081/nexus/content/groups/public/<URL>
<Release> <enabled> true </enabled> </release>
<Snapshots> <enabled> true> </enabled> </snapshots>
</Pluginrepository>
</Pluginrepositories>
</Profile>
</Profiles>
<Activeprofiles>
<Activeprofile> nexus </activeprofiles>
</Activaprofiles>
...
</Settings>
Activeprofiles is used for activation.
(3) configure the image so that Maven can only use private servers
<Settings>
...
<Mirrors>
<Mirror>
<ID> nexus </ID>
<Mirrorof> * <? Mirrorof>
<URL> http: // localhost: 8081/nexus/content/groups/public/</URL>
</Mirror>
</Mirrors>
<Profiles>
<Profile>
<ID> nexus </ID>
<Repositories>
<Repository>
<ID> central </ID>
<Name> http: // central </Name>
<Release> <enabled> true </enabled> </release>
<Snapshots> <enabled> true> </enabled> </snapshots>
</Repository>
</Repositories>
<Pluginrepositories>
<Pluginrepository>
<ID> central </ID>
<Name> http: // central </Name>
<Release> <enabled> true </enabled> </release>
<Snapshots> <enabled> true> </enabled> </snapshots>
</Pluginrepository>
</Pluginrepositories>
</Profile>
</Profiles>
<Activeprofiles>
<Activeprofile> nexus </activeprofiles>
</Activaprofiles>
</Settings>
In this configuration, the repository and plug-in repository IDs are both central, that is, they overwrite the configuration of the Super pom central repository. Their ULR can not be configured because all requests will access the private server address through images.
Original post address: http://springsfeng.iteye.com/blog/1456856