Maven Getting Started Guide ⑤: Using Nexus to build a maven

Source: Internet
Author: User
Tags sonatype sonatype nexus

1. Introduction

A special remote repository, which is built on a local area network, is to broker remote warehouses and deploy third-party components. When Maven needs to download the widget, it can be downloaded to the local repository if it is available, otherwise the remote repository will be requested to download the widget to the local repository.

We can use dedicated Maven warehouse management software, such as the Apache Archiva,artifactory,sonatype Nexus. Here we use the Sonatype Nexus.

2. Install Nexus

2. 1. Download Nexus

Nexus Pro is charged, here we download the open source Nexus OSS. Nexus provides two kinds of installation packages, one bundle package containing Jetty containers, and the other is a war package that does not contain a container. : Http://www.sonatype.org/nexus/go.

2. 2. Installing the Nexus using the bundle installation package

Unpack the installation package Nexus-2.8.1-bundle.zip, open a command prompt, enter the/nexus-2.8.1-01 directory, type the Nexus command (the bin directory can be added to environment variables for easy startup and exit of the Nexus):

Perform a Nexus install to mount the Nexus as a Windows service. You can set the service startup mode to Manual, then start the Nexus via Nexus start, and exit the Nexus via Nexus stop:

Open Browser, visit: http://localhost:8081/nexus/:

In the upper right corner, click Log in, use Username: admin, Password: admin123 login, you can use more features:

3. Nexus Pre-built warehouses

Click on the repositories link on the left to view the Nexus's built-in warehouses:

Nexus warehouses are divided into such categories as:

    • Hosted host repository: Primarily used to deploy artifacts that cannot be obtained from public warehouses (such as the JDBC Driver for Oracle) and project artifacts for themselves or third parties;
    • Proxy Agent Warehouse: Agent of the public remote warehouse;
    • Virtual Warehouse: Used to fit Maven 1;
    • Group Warehouse Groups: Nexus manages multiple warehouses with the concept of a warehouse group, so that we request warehouse groups directly in the project to request multiple warehouses managed by the Warehouse group.

4. Add Agent Warehouse

Take Sonatype as an example, add an agent repository for the public remote repository that proxies Sonatype. Click menu Add-proxy Repository:

Fill in Repository ID- sonatype;repository Name- sonatype Repository;

Remote Storage Location- http://repository.sonatype.org/content/groups/public/, Save:

Join the Sonatype Agent warehouse that you added to the public repositories Warehouse group. With the public repositories selected, in the Configuration tab, move the Sonatype Repository from the right Available repositories to the left Ordered Group Repositori Es,save Save:

4 O Search Widget

In order to better use the Nexus search, we can set all proxy warehouses Download remote Indexes to True, that is, allow the remote warehouse to download the index.

After the index has been downloaded successfully, under the Browse Index tab, you can browse to all the indexed artifact information, including coordinates, format, and Maven-dependent XML code:

With the index, we can search for:

6. Configure MAVEN to use

If we are successful, we can configure the Maven use, and later download the components, deployment artifacts, are managed by using a.

In the settings.xml file, configure a mirrored warehouse for all warehouses, with the address of the mirrored warehouse (here we use the address of the public repositories of the shared Warehouse group):

<mirrors>            <mirror>                <id>central</id>                <mirrorOf>*</mirrorOf> < !--* means to have all warehouses use the mirror-                 <name>central-mirror</name>                 <url>http://  localhost:8081/nexus/content/groups/public/</url>            </mirror>     </mirrors>

Maven Getting Started Guide ⑤: Using Nexus to build a maven

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.