1. Linux deployment Maven
Note: jdk must be installed first, there will be a corresponding relationship between maven and jdk (java -version) versions
Version correspondence ( must see! ): http://maven.apache.org/docs/history.html
Official tar package download address: https://maven.apache.org/download.cgi
java1.8 is java8, here I downloaded the meven3.9.1 version, pay attention to the corresponding version.
1.1 Download and decompress
The picture was taken later, and it has been updated to version 3.9.2. I installed version 3.91.
Upload to the /opt directory of the virtual machine, decompress it, it is recommended to install it under /usr/loacl
tar -zxvf apache-maven-3.9.1-bin.tar.gz
mv /opt/apache-maven-3.9.1/ /usr/local
1.2 Set up warehouse
Create a new ck directory under the /opt/apache-maven-3.9.1 directory
cd /opt/apache-maven-3.9.1
mkdir ck
Edit /opt/apache-maven-3.9.1/conf/settings.xml , add two places, note that the mirror tag is under mirrors.
<localRepository>/usr/local/apache-maven-3.9.1/ck</localRepository>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
1.3 Setting environment variables
vi /etc/profile
export MAVEN_HOME=/opt/apache-maven-3.9.1
export PATH=$PATH:$MAVEN_HOME/bin
source /etc/profile
1.4 Test
java -version
mvn -version
Successful installation
2. Install and deploy Maven on Windows
2.1 Download and decompress
Note: jdk must be installed first, there will be a corresponding relationship between maven and jdk (java -version) versions
Version correspondence ( must see! ): http://maven.apache.org/docs/history.html
Official tar package download address: https://maven.apache.org/download.cgi
Just unzip it after downloading, pay attention to the location of the directory, you need to remember.
2.2 Setting up warehouse
Add the mirror warehouse folder, create a new ck folder, open D:\App\apache-maven-3.9.1-bin\apache-maven-3.9.1\conf\setting.conf, add the Alibaba Cloud mirror warehouse, and specify ck for the warehouse.
<localRepository>D:\App\apache-maven-3.9.1-bin\ck</localRepository>
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
2.3 Setting environment variables
Add environment variables, note that the variable name must be MAVEN_HOME and cannot be changed.
Add the path environment variable. It is recommended to change the Path in the system variable instead of the Path in the user. Note that the two paths are different.
2.4 Testing
cmd to check whether the installation is successful
java -version #jdk
mvn -version #mvn
Successful installation