本文主要是介绍Centos7部署maven,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、下载
[root@nacos ~]# wget https://mirrors.bfsu.edu.cn/apache/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz
二、部署
[root@nacos ~]# tar -xf apache-maven-3.8.2-bin.tar.gz -C /usr/local/
三、环境变量配置
# 在文件末尾增加以下配置
[root@nacos ~]# vim /etc/profile
export M2_HOME=/usr/local/apache-maven-3.8.2
export PATH=$PATH:$M2_HOME/bin
四、vim settings.xml
4.1、替换maven源,阿里云的源
[root@nacos ~]# cd /usr/local/apache-maven-3.8.2/conf/
[root@nacos conf]# vim settings.xml
# 将(大概在159-166行)
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
# 替换成
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
4.2、指定下载资源位置
[root@nacos ~]# mkdir -p /usr/local/maven/repository
# 本地存储路径(大概53行)
[root@nacos conf]# vim settings.xml
<localRepository>/usr/local/maven/repository</localRepository>
4.3、指定JDK版本
# 277行这样添加
<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>
五、验证
[root@nacos ~]# mvn -version
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: /usr/local/apache-maven-3.8.2
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /usr/local/java/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.el7.x86_64", arch: "amd64", family: "unix"
这篇关于Centos7部署maven的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!