Linux(centos7)环境下配置maven3.6

原创
10/14 10:29
阅读数 27

Linux(centos7)环境下配置maven3.6

准备工作

  1. 下载压缩包,根据系统环境下载(x64)

  2. wget https://dlcdn.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
    
  3. 解压到指定目录,如保存到:/usr/local/maven

mkdir /usr/local/maven
tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /usr/local/maven/

配置环境变量

  1. 使用vim /etc/profile编辑profile文件
  2. 在/etc/profile底部加入如下内容
export MAVEN_HOME=/usr/local/maven/apache-maven-3.6.3
export PATH=$MAVEN_HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
  1. 最后使用source /etc/profile让profile文件立即生效。
$ source /etc/profile
  1. 修改库位置,/usr/local/maven/apache-maven-3.6.3/conf/settings.xml

  2. <localRepository>/home/repository</localRepository>
    
  3. 修改镜像地址,找到mirrors ,添加 aliyun 地址,如:

  4. <mirrors>
        <!-- mirror
         | Specifies a repository mirror site to use instead of a given repository. The repository that
         | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
         | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
         |
        <mirror>
          <id>mirrorId</id>
          <mirrorOf>repositoryId</mirrorOf>
          <name>Human Readable Name for this Mirror.</name>
          <url>http://my.repository.com/repo/path</url>
        </mirror>
         -->
    
           <mirror>
                <id>nexus-aliyun</id>
                <mirrorOf>*,!jeecg,!jeecg-snapshots,!getui-nexus</mirrorOf>
                <name>Nexus aliyun</name>
                <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            </mirror> 
    
      </mirrors>
    

测试安装结果

  1. 使用mvn -version,出现版本为 Apache Maven 3.6.3
$ mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/maven/apache-maven-3.6.3
Java version: 1.8.0_231, vendor: Oracle Corporation, runtime: /usr/local/jdk1.8.0_231/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.6.1.el7.x86_64", arch: "amd64", family: "unix"
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部