1、maven下載地址:https://maven.apache.org/download.cgi
下載 apache-maven-3.6.1-bin.tar.gz
2、在linux環境中創建maven目錄,/usr/local/maven,將maven安裝包上傳至此目錄中
3、配置環境變量
vi /etc/profile
將下面這兩行代碼拷貝到文件末尾並保存
MAVEN_HOME=/usr/local/maven/apache-maven-3.6.1
export PATH=${MAVEN_HOME}/bin:${PATH}
重載環境變量
source /etc/profile
4、查看結果
mvn –v
5、替換maven源,阿里雲的源
打開maven配置文件,比如:
vim /usr/local/maven/apache-maven-3.6.1/conf/settings.xml
找到<mirrors></mirrors>標簽對,添加一下代碼:
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror>
6、指定下載資源位置
<localRepository>/usr/local/maven/repository</localRepository>
7、指定JDK版本
<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>