CentOS7安装MAVEN
一、安装
1. MAVEN下载地址
http://maven.apache.org/download.cgi
2. 安装命令
wget https://downloads.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz
tar -xvf apache-maven-3.8.4-bin.tar.gz
mv apache-maven-3.8.4 /usr/local/apache-maven
3. 设置环境变量
vim /etc/profile
最后一行加入
#export JAVA_HOME=/usr/local/jdk1.8
export MAVEN_HOME=/usr/local/apache-maven
export PATH=$MAVEN_HOME/bin:$PATH
4. 生效环境变量
source /etc/profile
二、settings
配置添加国内源
vim /usr/local/apache-maven/conf/settings.xml
内容:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/root/.m2/repository</localRepository>
<pluginGroups>
<pluginGroup>com.spotify</pluginGroup>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>tomcat</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
<server>
<id>3rdParty</id>
<username>私有nexus仓库账号</username>
<password>私有nexus仓库密码</password>
</server>
</servers>
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>3rdParty</id>
<mirrorOf>*</mirrorOf>
<name>3rdParty</name>
<url>私有nexus仓库地址</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>3rdParty</id>
<repositories>
<repository>
<id>3rdParty</id>
<name>3rdParty</name>
<url>私有nexus仓库地址</url>
<releases>
<updatePolicy>always</updatePolicy>
<enabled>true</enabled>
</releases>
<!-- snapshots默认是关闭的,需要手动开启 -->
<snapshots>
<updatePolicy>always</updatePolicy>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>android</id>
<properties>
<android.sdk.path>
/root/adt-bundle-windows-x86_64-20140702/sdk
</android.sdk.path>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>3rdParty</activeProfile>
<activeProfile>android</activeProfile>
</activeProfiles>
</settings>