文章目录
1、下载Maven
Maven 下载地址:https://maven.apache.org/download.cgi
这里我们下载 apache-maven-3.6.3-bin.tar.gz
2、在 linux 环境中创建 maven 目录,将 maven 安装包上传至此目录中
mkdir /usr/local/maven
3、解压maven包
tar -zxvf apache-maven-3.6.3-bin.tar.gz
4、配置环境变量
vi /etc/profile
将下面这两行代码拷贝到文件末尾并保存
MAVEN_HOME=/usr/local/maven/apache-maven-3.6.3
export PATH=${MAVEN_HOME}/bin:${PATH}
5、重载环境变量
source /etc/profile
6、查看结果
mvn -v
7、替换maven源,阿里云的源
打开 maven 的 setting.xml 文件,在 mirrors 标签里面添加阿里云源
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
8、指定下载资源位置
<localRepository>/usr/local/maven/lib</localRepository>
9、指定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>