Maven: Learn how to configure the private server nexus

Source: Internet
Author: User

 

(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

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.