1.Java环境
2.下载
3.安装
$ tar xvf apache-maven-3.6.3-bin.tar.gz
$ mv apache-maven-3.6.3 ~/app/
4.环境变量
$ vim ~/.bash_profile
export MAVEN_HOME=$HOME/app/apache-maven-3.6.3
export PATH=${PATH}:$MAVEN_HOME/bin
$ source ~/.bash_profile
5.版本
$ which mvn && mvn -v
/Users/zeze/app/apache-maven-3.6.3/bin/mvn
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/zeze/app/apache-maven-3.6.3
Java version: 1.8.0_241, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.3", arch: "x86_64", family: "mac"
6.配置全局默使用阿里云镜像
https://maven.aliyun.com/mvn/view
文件: $MAVEN_HOME/conf/settings.xml
<mirrors>
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
<!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
</mirrors>