Ubuntu 配置Maven

  |   0 评论   |   883 浏览

Ubuntu 配置Maven

*非特别说明,默认root用户登录

1.下载maven

下载页面: https://maven.apache.org/download.cgi

$ wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.zip  
$ unzip apache-maven-3.5.3-bin.zip 
$ sudo mv apache-maven-3.5.3 /opt/maven/

2.添加阿里云Maven仓库

编辑文件 settings.xml

<mirrors>
     <mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>*</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
</mirrors>

3.配置Maven环境变量

添加如下内容到文件/etc/profile和~/.bashrc中

export M2_HOME=/opt/tool/maven
export PATH=$PATH:$M2_HOME/bin

配置生效,执行如下命令:

source /etc/profile

4.检验配置结果

$ mvn -v
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T03:49:05+08:00)
Maven home: /opt/tool/maven
Java version: 1.8.0_171, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-31-generic", arch: "amd64", family: "unix"

评论

发表评论