Centos7安装maven
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
找到
<mirror> <id>alimavenid> <name>aliyun mavenname> <url>http://maven.aliyun.com/nexus/content/groups/public/url> <mirrorOf>centralmirrorOf> mirror>
6、指定下载资源位置
<localRepository>/usr/local/maven/repositorylocalRepository>
7、指定JDK版本
<profile> <id>jdk-1.8id> <activation> <activeByDefault>trueactiveByDefault> <jdk>1.8jdk> activation> <properties> <maven.compiler.source>1.8maven.compiler.source> <maven.compiler.target>1.8maven.compiler.target> <maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion> properties> profile>