Install maven on Linux (CentOS operating system)

1. Download the installation package from Maven official website

Maven official website address
insert image description here
I downloaded version 3.8
insert image description here
I installed maven operating system CentOS 7.7 64 bits

I upload the downloaded maven installation package to the server through Xftp 7
insert image description here
insert image description here
First create two directories in /usr/local/

[root@localhost local]# mkdir maven
[root@localhost maven]# mkdir repository

I uploaded the maven installation package to the /usr/local/maven directory of the service

[root@localhost /]# cd /usr/local/maven

insert image description here
Unzip apache-maven-3.8.8-bin.tar.gz

[root@localhost maven]# tar -zxvf apache-maven-3.8.8-bin.tar.gz
[root@localhost maven]# ls
apache-maven-3.8.8  apache-maven-3.8.8-bin.tar.gz  repository

Two, configure maven

Modify settings.xml
[root@localhost maven]# vim /usr/local/maven/apache-maven-3.8.8/conf/settings.xml

1. Change the mirror address

insert image description here

<mirror>
   <id>nexus-aliyun</id>
   <mirrorOf>central</mirrorOf>
   <name>Nexus aliyun</name>
   <url>https://maven.aliyun.com/repository/public</url>
</mirror>

2. Use a custom warehouse

insert image description here

<localRepository>/usr/local/maven/repository</localRepository>

Press the Esc key to exit the editing mode, enter: wq to save and exit the vim editor

3. Configure maven environment variables

edit profile file

[root@localhost maven]# vim /etc/profile

Add the following environment variables at the end of the profile file
insert image description here

export MAVEN_HOME=/usr/local/maven/apache-maven-3.8.8
export PATH=$PATH:$MAVEN_HOME/bin

Press the Esc key to exit the editing mode, enter: wq to save and exit the vim editor

refresh source

root@localhost maven]# source /etc/profile

Check if the installation is successful

[root@localhost maven]# mvn -v

insert image description here
success

Guess you like

Origin blog.csdn.net/qq407995680/article/details/132360404
Recommended