Ubuntu18 Maven安装及环境变量配置

Ubuntu 18.04 LTS Maven安装及环境变量配置。

1、Maven官网下载

https://maven.apache.org/download.cgi

2、解压到指定路径

sudo mkdir /opt/maven
sudo tar -zxvf apache-maven-3.5.4-bin.tar.gz /opt/maven

3、环境变量配置及本地仓库修改

  • 编辑配置文件,添加阿里云镜像及本地仓库地址
sudo gedit /opt/maven/conf/settings.xml
  • 复制以下内容到配置文件

<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>/home/zhoulipeng/Develop/RepositorylocalRepository>
    <pluginGroups>pluginGroups>
    <proxies>proxies>
    <servers>servers>
    <mirrors>
        
        <mirror>
            <id>nexus-aliyunid>
            <name>Nexus aliyunname>
            <mirrorOf>*mirrorOf>
			<url>http://maven.aliyun.com/nexus/content/groups/public/url>
        mirror>
    mirrors>
    <profiles>
    profiles>
settings>
  • 环境变量配置
sudo gedit /etc/profile
  • 文尾添加以下内容
#Maven环境变量,填写个人maven安装路径
export M2_HOME=/opt/apache-maven-3.5.4
export PATH=${M2_HOME}/bin:$PATH
  • 当前bash环境变量生效(重启完全生效)
source /etc/profile
  • 验证maven ,输出maven版本信息表示配置成功
mvn -v

你可能感兴趣的:(Ubuntu,maven)