美文网首页
Maven 配置本地仓库和镜像阿里云

Maven 配置本地仓库和镜像阿里云

作者: 六年春华 | 来源:发表于2019-10-24 17:46 被阅读0次

1. 配置本地的仓库

  1. 找到maven文件夹下面的conf里面的settings.xml文件
  2. 找到里面的localRepository标签,可以看到默认位置是:
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  1. 在下面添加自己的本地仓库路径:
<localRepository>/Users/light6/mavenRepo</localRepository>

之后如下图:


maven本地仓库.png

2. 配置阿里云为maven的中央仓库

因为在中央仓库下载jar的时候很慢,便用阿里云提供的maven仓库下载jar可以快很多

  1. 找到在settings.xml文件里的mirrors节点
  <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>
  1. 在mirrors节点添加如下子节点:
<mirror>  
    <id>nexus-aliyun</id>  
    <mirrorOf>central</mirrorOf>    
    <name>Nexus aliyun</name>  
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>  
</mirror>

之后如下图:


maven阿里云.png

相关文章

网友评论

      本文标题:Maven 配置本地仓库和镜像阿里云

      本文链接:https://www.haomeiwen.com/subject/coudvctx.html