It is not the core concept of Maven, it is just a special Maven repository that derives from it. By setting up your own network, you can reduce your central warehouse load, save bandwidth, accelerate MAVEN builds, build your own deployment, and more efficiently use MAVEN. Nexus is also currently the most popular MAVEN warehouse management software.
1. Install Nexus
Nexus is a typical Java Web application that has two installation packages, a bundle package containing the jetty container, and a war package that does not contain a Web container.
1) Download Nexus
Readers can download the latest nexus from the official website http://www.sonatype.org/nexus/, or download it to the path I share http://download.csdn.net/detail/amuguelove/ 6578111 (even if you want a point, take their own, no points to ignore this address it).
2) Bundle way to install Nexus
A. First look at the extracted directory, structure:
NEXUS-2.6.2-01: This directory contains the files needed to run the nexus, such as startup scripts, dependent jar packages, and so on.
Sonatype-work: This directory contains nenus generated configuration files, log files, warehouse files, and so on.
Where the first directory is required to run the Nexus, and the second is not required, the Nexus will dynamically create the directory when it runs.
B. Configure the path to start the Nexus
First add the following address under the environment variable path: D:\j2ee\nexus-2.6.2-01-bundle\nexus-2.6.2-01\bin; then start the Nexus service under CMD:
If you see the above output, it means that the boot was successful. Then open the browser access: Http://localhost:8081/nexus can see the Nexus interface, such as:
You can click Login in the upper right corner of the interface to login, and the Nexus Default admin username and password is admin/admin123.
2. The Nexus Index
At this point you do not get any results using the Nexus Search plug-in, in order to be able to search the MAVEN Central Library, you first need to set up a nexus to download the MAVEN Repository remote index. Such as:
Click on the left navigation bar repositories, you can link to this page, select Central, click Configuration, there is a download Remote indexes config, the default state is false, change it to true, ' Save ', click administration==> Scheduled Tasks, there is a task to update index, this is the nexus in the day after tomorrow to run a task to download the Central Warehouse index. Because the central warehouse content is more, so its index file is larger, Nexus download the file also need a relatively long time. Please wait patiently for the reader. If the network speed is not good, you can use other people to set up the Nexus. It will be introduced later. Task graph running for Nexus background:
3. Configure Maven to download widgets from Nexus
1) Configure the Nexus in the Pom, which is only valid for the current MAVEN project.
| 12345678910111213 |
<repositories> <repository> <id>nexus</id> <name>nexus Repository</name> <url >http://localhost:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> |
2) Configure the profile element in settings.xml so that all MAVEN projects on this machine will use their own maven.
| 1234567891011121314151617181920212223242526 |
<mirrors> <mirror> <id>central< /id> <mirrorof>*</mirrorof> <name>human readable name for this mirror.</name> <url> http://localhost:8081/nexus/content/groups/public/</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <repositories> <repository> <id>nexus</id> <name> nexus</name> <url>http://localhost:8081 /nexus/content/groups/public/</url> <span></ Span><releases> <enabled >true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile></profiles > |
All maven download requests above are configured via the Nexus only to make full use of the function.
4. Deploy Widgets to Nexus
1) Configure in POM
| 12345678910111213141516171819 |
<project> ... <distributionManagement> <snapshotRepository> <id>user-snapshots</id> <name>user Project snapshots</name> <url>http://localhost:8081/nexus/content/repositories/ myuserrepossnapshots/</url> </snapshotrepository> <repository> <id>user-releases</id> < Name>user Project release</name> <url> http://localhost:8081/nexus/content/repositories/myuserreposrelease/</url> </repository> </distributionmanagement> ...</ Project> |
2) Configure the authentication information in Settings.xml, the Nexus Warehouse is read-only for anonymous users.
| 123456789101112131415 |
<servers> <server> <id>user-snapshots</id> <username>lb</username> <password>123456</password> </server > <server> <id>user-releases</id> <username>lb</username> <password>123456</password> </server > </servers> |
Finally, if you do not want to build your own nexus, or if you update index is slow, you can use Oschina to build a nexus, the address is as follows: http://maven.oschina.net/index.html, such as:
We recommend that you can bookmark this site in the browser, usually can also be used to see some of the dependencies of the components, such as the lower right corner of the display.
Create a maven-Nexus