What is a Maven private server

Private server refers to the private server, is set up in the local area network of a special remote warehouse, the purpose is to agent the remote warehouse and deploy the third party to build. With a private server, when Maven needs to download a component, it directly requests the private server and downloads it to the local repository if it exists on the private server. Otherwise, the private server requests an external remote repository to download the component to the private server and provide it to the local repository for download

II. Maven installation

1. Download address


2. The server installs the JDK environment

Be sure to follow the JDK, not the JRE

Yum install Java -- 1.8.0 comes with its - devel. X86_64

Reference: https://www.cnblogs.com/yaun1498078591/p/10368884.html

3. Install Maven

Maven [root@localhost ~]# CD /data/tools/ Maven [directory]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz [root @ localhost The SRC] # tar - ZXVF apache maven - 3.8.1 - bin. Tar. Gz

4. Configure system environment variables

[root@localhost JVM]# vim /etc/profile export JAVA_HOME=/usr/lib/ JVM/java-1.8.0-OpenJDK-1.8.292.b10-2.el8.x86_64 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export $PATH =$PATH:$JAVA_HOME/bin Export Maven_Home =/data/tools/maven/apache-maven-3.8.1 Export PATH=$PATH:$Maven_HOME /bin [root@localhost jvm]# source /etc/profile

5. Verify that Maven is installed successfully

Execute the command: MVN -v Apache Maven 3.8.1 c21c65bdfed0f71a2f2ada8b84da59348c4c5d (05) Maven home: /data/tools/maven/apache-maven-3.8.1 Java version: 1.8.0_292, vendor: Red Hat, Inc., runtime: /usr/lib/ JVM/java-1.8.0-OpenJDK- / JRE Default Locale: en_US, Platform Encoding: UTF-8 OS Name: "Linux ", version: "4.18.0-301.1.el8.x86_64", arch: "amd64", family:" Unix"

3. Install Nexus

1. Download address


2 source code installation

[root@localhost jvm]# cd /data/tools/maven/ [root@localhost src]# wget https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.11.0-01-unix.tar.gz [root @ localhost SRC] # tar ZXVF. - Nexus-3.11.0-01 -unix.tar.gz [root@localhost SRC]# mv nexus-3.11.0-01 /usr/local/nexus

3. Start the nexus

The default port is 8081. If you want to change the port, you can change the boot port in the etc/nexus-default.properties configuration:

[root@localhost src]# /data/tools/maven/nexus-3.11.0-01/bin/nexus start
WARNING: ************************************************************
WARNING: Detected execution as "root" user.  This is NOT recommended!
 WARNING: ************************************************************
 Starting nexus

Root is not recommended. Just create a new user. This warning does not affect the normal access and use of the Nexus.

4. Open port 8081

[root@localhost src]# firewall-cmd --add-port=8081/tcp --permanent
[root@localhost src]# firewall-cmd --reload

Browser access

This will set up the Nexus service, the default administrator account password is admin/admin123

Refer to the link: https://my.oschina.net/u/2963821/blog/1806035

III. Configuration and use in the project

1. Configure Maven on the development computer

The Maven configuration settings.xml configuration for the native code-writing computer is as follows:

<servers> <server> <id>usr-releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>usr-snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers> ...... <profiles> <profile> <id>usr-private-repo</id> <repositories> <repository> <id>usr-releases</id> The < url > < / url > < releases > < enabled > true < / enabled > < / releases > <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>usr-snapshots</id> The < url > < / url > < releases > < enabled > false < / enabled > < / releases > <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> </profiles> ...... <activeProfiles> <activeProfile>usr-private-repo</activeProfile> </activeProfiles>

2. Deploy DistributionManagement in your project’s POM file so that you can upload the JARs you are distributing to your private server

<distributionManagement> <! -bb2 <repository> <id>usr-releases</id> -- Settings.xml <id> --> <repository> <id>usr-releases</id> The < url > < / url > < / repository > < snapshotRepository > < id > usr - snapshots < / id > The < url > < / url > < / snapshotRepository > < / distributionManagement >