Linux_CentOS 7.2 64之安装apache-maven-3.6.3

1. 下载maven安装包,并上传到linux系统中。

maven 3.6.3 linux安装包

2. 解压

tar -xvf apache-maven-3.6.3-bin.tar.gz 

3. 创建一个maven文件夹

mkdir maven

4. 将解压后的 apache-maven-3.6.3 文件夹,剪切到maven文件夹中,并使用pwd命令,找到apache-maven-3.6.3文件夹位置

/wangqinmin/maven/apache-maven-3.6.3   (这是我运行pwd的位置)

5. 在maven文件夹中,创建maven仓库文件夹

mkdir repository

 并pwd找到 创建的repository文件夹的位置 

/wangqinmin/maven/repository   (这是我pwd查到的位置)

6. 配置环境变量

vim /etc/profile

7. 在最后一行,添加配置(注意这里面 /wangqinmin/maven/apache-maven-3.6.3 这个目录,是我上面的pwd命令拿到的位置,你们配置的时候,要改成自己的

export MAVEN_HOME=/wangqinmin/maven/apache-maven-3.6.3
export PATH=$PATH:$MAVEN_HOME/bin

8. 在apache-maven-3.6.3目录下,找到conf,再找到setting.xml文件

使用命令

vim setting.xml

找到以下位置:

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

并在这段 注释后添加:  (这里就是  添加上面创建的 repository文件夹位置

 <localRepository>/wangqinmin/maven/repository</localRepository>

结果为:

   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

 <localRepository>/wangqinmin/maven/repository</localRepository>

9. 再找到 这段注释

  <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>
     -->
  </mirrors>

再在  --> 后面添加 

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

结果为:

    <!-- 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>alimaven</id>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>

10: 保存修改的文件  wq命令

11. 执行(刷新配置)

source /etc/profile

12. 运行 mvn -version 查看是否安装成功。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值