Build a Maven repository using nexus (local private server)

Source: Internet
Author: User
Tags sonatype sonatype nexus

 

When using Maven, Maven downloads the jar package that the project depends on by default in the central repository, to the local disk directory (if not configured, it is under the user directory /. m2/repository folder ). If a Maven private server is built in the company, the developer directs the repository address to the Intranet repository address. The jar package is available in the private server, and the download speed is faster than that of the remote server, if the local repository does not exist, it is automatically downloaded remotely and saved locally. This article uses nexus to build a private server.

1. Download nexus

Search for sonatype nexus in the browser to go to the official website and find the download. Decompress the package as follows:

2. Install nexus

Go to the nexus/bin/JWS folder and see the following:

My computer is win7 32-bit, so click on the windows-x86-32 folder, double-click the install-nexus.bat to install nexus into a service, after completion, in the Windows Service will see as shown in:

Enter http: // localhost: 8081/nexus in the browser and you will see the following page, indicating that the installation is successful.

3. Configure nexus

After step 2 is complete, click the log in button in the upper-right corner of the nexus, log in with the initial password admin/adming123 as the administrator, and click the [repositories] menu on the left to view the following repositories:

Right-click Apache snapshots and the central repository, and click Update index in the context menu to update the jar index.

By default, the indexes downloaded by nexus and jar packages are stored in the sonatype-work folder under the Nexus directory.

For example, if my nexus installation directory is D: \ your lopment \ nexus-2.7, the downloaded jar and index will be saved under D: \ your lopment \ sonatype-work, click snoatype-work --> nexus to view the indexer and storage folders.

Some simple configurations:

Click Apache snapshots repository, configure as follows, enable remote index download, and click Save

Add existing repositories, such as Apache snapshots, 3 dpart, and central to the public group and directly remove the right warehouse to the left on the interface. The effect is as follows:

4. Use nexus in Maven

Find the maven configuration file, that is, settings. xml under apache-maven-3.1.1/Conf

Add the following configuration under the mirrors node:

 

<Mirrors> <! -- Mirror | specifies a repository mirror site to use instead of a given repository. the repository that | this mirror serves has an ID that matches the mirrorof element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique guest ss the set of mirrors. | <mirror> <ID> mirrorid </ID> <mirrorof> repositoryid </mirrorof> <Name> human readable name for this mirror. </Name> <URL> http://my.repository.com/repo/path </URL> </mirror> --> <mirror> <ID> nexus </ID> <mirrof> central </mirrorof> <Name> internal nexus repository </Name> <URL> HTTP: // localhost: 8081/nexus/content/groups/public/</URL>, which describesPublic reposiories information,This address is his address, which can be viewed on the Interface </mirror>. Here, localhost is set up for testing on the local machine. If it is a company warehouse, you can change it to the Intranet IP address of the company. </Mirrors>

 

 

 

In this way, after the configuration, we will use the private server when using Maven. Instead of obtaining data from the remote server. (Maven is downloaded from a remote central repository by default)

 

In this configuration file, a node named localrepository is used to configure the address for storing the jar package downloaded by maven. If it is not configured, the jar package will be downloaded to the user folder on drive C. m2 folder. You can specify a directory as follows:

The jar package downloaded by MAVEN will be saved under D:/devolopment/mavenrepository

Summary: The Usage After nexus is shown in figure

 

 

 

 

  

 

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.