CentOS7 安装 Maven

# 以3.6.1版本为例,下载 maven 包到本地
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz

# 解压
tar -zxvf apache-maven-3.6.1-bin.tar.gz

# 创建安装目录,这里安装到了 /usr/local/maven
mkdir /usr/local/maven

# 将解压后的文件移动到安装目录
mv -f apache-maven-3.6.1 /usr/local/maven

# 配置环境变量,在后面追加以下文本
vim /etc/profile

# maven environment
export MAVEN_HOME=/usr/local/maven/apache-maven-3.6.1
export PATH=$PATH:${MAVEN_HOME}/bin

# 配置阿里云 maven 镜像,在 mirrors 中加入
vim /usr/local/maven/apache-maven-3.6.1/conf/settings.xml 

<mirror>  
  <id>alimaven</id>
  <name>aliyun maven</name>  
  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
  <mirrorOf>central</mirrorOf>          
</mirror>

# 使配置生效
source /etc/profile

# 测试安装
mvn --version

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×