Linux install Nexus repository and IntelliJ idea integrated private maven

Source: Internet
Author: User
Tags configuration settings maven central sonatype

A few days ago, the company made a Java project, using Nexus Repository to build a private Maven library, now the original private NuGet also moved to the Nexus Repository, the following describes the next build process:

Https://help.sonatype.com/display/NXRM3/Download

Official Download tar package current nexus-3.8.0-02-unix.tar.gz

Uploading to a Linux server using the Xshell RZ command

Unzip the file: Tar-zxvf nexus-3.8.0-02-unix.tar.gz (will extract two folders)

Go to unzip file CD nexus-3.8.0-02

Edit configuration file: VI etc/nexus-default.properties

Change the port number in the configuration file (default port number 8081):

application-port=5006

(If you change the working path, modify nexus-work, such as nexus-work=${user.home}/sonatype-work/nexus)

Go to Bin folder: CD bin

Start Nexus Service:./nexus start

View service status:./nexus status

Access address ip:5006, the following interface appears:

Default User: admin admin123

After landing you can create different types of warehousing, about Nexus Repository warehousing instructions are as follows:

One, component name explanation:

(1) Maven-central:maven Central Library, pull jar from https://repo1.maven.org/maven2/by default

(2) Maven-releases: Private repository release jar

(3) Maven-snapshots: Private library Snapshot (Debug version) jar

(4) Maven-public: Warehouse Grouping, the above three warehouses together to provide services, in the local MAVEN base configuration settings.xml used.

Two, the Nexus default warehouse type has the following four kinds:

(1) Group (Warehouse Group type): Also called the Group Warehouse, for the convenience of developers to set their own warehouse

(2) Hosted (host type): Publishing warehouse for internal projects (internal developer, warehouse published)

(3) Proxy (proxy type): The warehouse looking for data from the Remote central repository (you can click on the configuration page of the corresponding warehouse to check the remote Storage Location property's value is the path of the broker's repository)

(4) Virtual type: Virtual Warehouse

Policy: Indicates whether the warehouse is a release or snapshot (Snapshot) version of the repository

Iv. warehouses under the public repositories:

(1) 3rd party: A component repository that cannot be obtained from a public warehouse, that is, a third-party-dependent warehouse, which is typically downloaded by internal personnel and published

(2) Apache snapshots: Using the agent Apachemaven Warehouse snapshot version of the component warehouse

(3) Central: The repository used to proxy the release builds in the MAVEN repository

(4) Central M1 Shadow: A component-mirrored warehouse used to provide a release version of the M1 format in a centralized warehouse

(5) Codehaus snapshots: The warehouse used to proxy the snapshot version artifacts of the Codehausmaven warehouse

(6) Releases: The release warehouse of the release module in the internal module, which is used to deploy the host type warehouse of the internal release build component; release is the release version

(7) Snapshots: Publish the warehouse of the internal snapshot module, which is used to deploy the host type warehouse that manages the internal snapshot version artifacts; Snapshots is the snapshot version, which is the unstable version

So the order of custom built warehouse group agent warehouses is: releases,snapshots,3rd party,central. You can also use Oschina to put it in front of Central and download the package faster.

Intellij idea integrates private maven:

Find Maven configuration file Setting.xml (in idea's file Setting) operation

(If the Setting.xml file is not configured under the path, you can copy a past in the plugins\maven\lib\maven3\conf of the idea installation path,

My Computer in C:\Program Files\jetbrains\intellij idea 2017.3.2\plugins\maven\lib\maven3\conf)

The following configuration is added in Setting.xml:

<servers>

<server>

<id>nexus</id>

<username>admin</username>

<password>admin123</password>

</server>

</servers>

Using idea to open or create a new project, add the following configuration under Add <project></project> nodes in the project's Pom.xml file:

Agent Repository

<repositories>

<repository>

<ID>maven-central</ID>

<name>maven-central</name>

<URL>http://ip:port/repository/maven-central/</url>

<snapshots>

<enabled>true</enabled>

</Snapshots>

<releases>

<enabled>true</enabled>

</releases>

</Repository>

</repositories>

If you need to upload the source to Maven, add the following configuration to the <project></project> node in the project's Pom.xml file:

Jar Package Release Repository

<distributionmanagement>

<snapshotrepository>

<ID>nexus</ID>

<name>nexus snapshot</name>

<URL>http://ip:port/repository/maven-snapshots/</url>

</snapshotrepository>

<repository>

<ID>nexus</ID>

<name>nexus release</name>

<URL>http://ip:port/repository/maven-releases/</url>

</Repository>

Website Information

<!--<site>

<id>nexus</id>

<name>nexus sites</name>

<url>dav:http://ip:port/repository/maven-snapshots/</url>

</site>-->

</distributionmanagement>

<build>

<plugins>

// Upload Source Plugin

<plugin>

<artifactid>maven-source-plugin</artifactid>

<version>2.1</version>

<configuration>

<attach>true</attach>

</Configuration>

<executions>

<execution>

<phase>compile</phase>

<goals>

<goal>jar</goal>

</Goals>

</Execution>

</Executions>

</Plugin>

</Plugins>

</Build>

Attention:

The ID node values in Setting.xml and pom.xml must be identical,

Pom.xml the value of the version node in the header file contains snapshot when Maven considers the snapshot version to be published to the Maven-snapshots warehouse,

Not included in the release version, published to the Maven-releases warehouse

After the configuration is complete, you can use idea to publish the jar to the private repository or pull the jar, and open the idea Maven tool in the way such as:

When you add Maven Project view, the tool interface is displayed on the right side of idea, and the button is clicked to complete the operation.

Ps:idea to create a MAVEN project, change the default JDK version to 1.8 as follows:

To modify MAVEN's Setting.xml file, add the following:

<profile>

<id>jdk-1.8</id>

<activation>

<activeByDefault>true</activeByDefault>

<jdk>1.8</jdk>

</activation>

<properties>

<maven.compiler.source>1.8</maven.compiler.source>

<maven.compiler.target>1.8</maven.compiler.target>

<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>

</properties>

</profile>

Take effect after restarting idea.

Linux install Nexus repository and IntelliJ idea integrated private 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.