Maven需改仓库地址为阿里云&修改本地仓库地址

时间:2019-11-02
本文章向大家介绍Maven需改仓库地址为阿里云&修改本地仓库地址,主要包括Maven需改仓库地址为阿里云&修改本地仓库地址使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

修改Maven的配置文件

vim conf/settings.xml

修改为阿里云的远程仓库地址

  <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,!mapr-releases</mirrorOf>
      <name>Nexus aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
   
    <mirror>
      <id>mapr-public</id>
      <mirrorOf>mapr-releases</mirrorOf>
      <name>mapr-releases</name>
      <url>https://maven.aliyun.com/repository/mapr-public</url>
    </mirror>
  </mirrors>

修改本地仓库的地址

在settings标签內 复制被注释的localRepository 修改为自己的地址

<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
   | The path to the local repository maven will use to store artifacts.
   | 
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <localRepository>/usr/local/apache-maven-3.5.4/local_repository</localRepository>

原文地址:https://www.cnblogs.com/gitgub/p/11783936.html