Build nexus private maven private server

Nexus is a powerful Maven warehouse manager, which greatly simplifies the maintenance of its own internal warehouse and the access to external warehouses. With nexus, you can fully control access to and deploy every Artifact in the warehouse you maintain in one place. Nexus is a "out of the box" system. It does not need a database. It uses file system and Lucene to organize data. Nexus uses ExtJS to develop the interface and Restlet to provide complete REST APIs, which are integrated with Eclipse through m2eclipse. Nexus supports WebDAV and LDAP security authentication.

Environmental description

CentOS 6.8, JDK8, Sonatype Nexus, Maven IP: root user operation

Installing Nexus

Premise: JDK8 has been installed and environment variables have been configured

Download Nexus

Download Nexus (here, I use nexus-2.11.2-03-bundle.tar.gz), download address: , we can also enter the following command on the command line of the server to download nexus-2.11.2-03-bundle tar. GZ installation files.

# wget

You can also link to: Download

Unzip Nexus

# mkdir nexus
# tar -zxvf nexus-2.11.2-03-bundle.tar.gz -C nexus
# cd nexus
# ls
nexus-2.11.2-03 sonatype-work
(One nexus Service, a private library directory)

Edit Nexus

Edit Nexus Directory and port information (default, reserved)

# cd nexus-2.11.2-03
# ls
bin conf lib LICENSE.txt logs nexus NOTICE.txt tmp

Check the directory structure and jetty runs

# cd conf
# vi
# Jetty section
# Nexus section

Edit nexus script and configure RUN_AS_USER parameter

# vi /usr/local/nexus/nexus-2.11.2-03/bin/nexus

Replace with:


Open port 8081 in firewall

#vi / etc/sysconfig/iptables add

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT

Restart firewall after saving

# service iptables restart

Start nexus

# /usr/local/nexus/nexus-2.11.2-03/bin/nexus start
Starting Nexus OSS...
Started Nexus OSS.

Visit nexus

Open in browser:

Login to nexus

The default user name is admin and the default password is admin123.

Nexus configuration (after login)

Set administrator mailbox

Menu Administration/Server configuration mailbox service address (if you forget the password, you can retrieve the password through this mailbox)

Set user mailbox

Configure the email address for users to retrieve the password when they forget:

User change password

Warehouse type

  • Group warehouse group: Nexus uniformly manages multiple warehouses through the concept of warehouse group, so that we can directly request the warehouse group in the project to request multiple warehouses managed by the warehouse group;
  • hosted host warehouse: mainly used to publish internal project components or third-party project components (such as purchased commercial components) and components that cannot be obtained from public warehouses (such as JDBC driver of oracle). Proxy warehouse: proxy public remote warehouse;
  • virtual warehouse: used to adapt Maven 1;

The commonly used warehouse types are hosted and proxy.

Description of common types of Hosted warehouse:

  • The release warehouse of the release module in the internal module of releases
  • snapshots is the repository of the internal SNAPSHOT module
  • The 3rd party is a warehouse that the third party relies on. This data is usually downloaded and released by internal personnel

If the local warehouse of Maven project does not have a corresponding dependency package, it will go to the Nexus private server to download it. If the Nexus private server does not have this dependency package, it will go back to the remote central warehouse to download the dependency. These central warehouses are proxies. After downloading the Nexus private server successfully, download it to the local Maven library for project reference.

Set proxy warehouse

Set the proxy repository (Apache Snapshots/Central/Codehaus Snapshots) to allow remote downloading, as shown below.


Installation and configuration of Maven local library

Download Maven

To link Download Maven

Configure Maven environment variables

vim /etc/profile


source /etc/profile

Configure local Maven

Copy the configuration file settings. In Maven's conf directory XML, renamed settings Lyz XML, the content after modifying the configuration file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="" 
 <!--Configure permissions,Use default user-->
     <!-- Private library address-->
     <!--Plug in library address-->
 <!--activation profile-->


Where, in the configuration file


Description the local warehouse is located in D:/Maven_Repository/.m2/repository directory.

The following configuration items in the configuration file.


Consistent with the link in the figure below:

Configuring Eclipse Maven


Project construction and release

First of all, we need to create the POM The following contents are added to the XML file to publish the Jar built by the project to Maven private warehouse

        <name>Nexus Release Repository</name>
        <name>Nexus Snapshot Repository</name>

Configuration description

POM in the project In the XML file, if the version is configured as follows:


The corresponding directory after publishing to Maven private warehouse is as follows:

If the version is configured as follows:


The corresponding directory after publishing to Maven private warehouse is as follows.

Complete POM The configuration of the XML file is as follows.

<project xmlns="" xmlns:xsi=""
            <name>Nexus Release Repository</name>
            <name>Nexus Snapshot Repository</name>
       Omitted here....

The specific release steps are as follows:

Right click POM xml->Run as->Maven build->

The private library in the figure above is empty. Right click POM XML - > run as - > Maven build (at this time, the version of pom.xml file is 0.0.1-SNAPSHOT).

After construction,

Note that the project has been built and released to our Maven private warehouse.

At this time, the Release directory in the figure above is empty. At this time, we modify POM The version of XML is 0.0.1-RELEASE. Right click pom.xml again XML - > run as - > Maven build to build the project. The published directory is as follows:

Note that the project has been built and released to our Maven private warehouse.

Finally, we add a third-party Jar dependency to our Maven private warehouse. The specific operations are as follows:

As shown in the figure above, the third-party dependency private warehouse is empty. We upload the third-party dependency to our Maven private warehouse according to the following steps.


As shown in the figure above, the third-party dependency has been uploaded to our Maven private warehouse. Original glacier Technology Core configuration of enterprise maven


Posted by Goafer on Thu, 12 May 2022 10:22:45 +0300