pom.xml和settings.xml的下载优先级

一、区别

指令打包:mvn package, 

    先加载pom.xml的repositories,再加载setttings.xml中的mirrors,即先从pom.xml中的url下载,若没有再从settings.xml中的url下载

idea下载(有一个坑,若配置过maven的settings.xml,此时的settings.xml文件名不为setttings.xm则idea识别不到,会使用默认的settings.xml,这和myeclipse不同)

  只加载setttings.xml中的mirrors,不加载pom.xml的repositories  

 

二、配置

setting.xml的仓库下载配置如下

1 <mirrors>
2   <mirror>
3     <id>alimaven</id>
4     <mirrorOf>central</mirrorOf>
5     <name>aliyun maven</name>
6            <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
7   </mirror>
8 </mirrors>
settings.xml

 

pom.xml的仓库下载配置如下

1 <repositories>
2     <repository>
3         <id>alimaven</id>
4         <name>central</name>
5         <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
6     </repository>
7 </repositories>
pom.xml

 

三、外网迁内网时,maven仓库的jar导入不了

 

1 <mirror>
2     <id>local</id>
3     <mirrorOf>*</mirrorOf>
4     <name>local</name>
5     <url>file://d:\\repo\maven</url>
6 </mirror>
settings.xml

 

posted @ 2019-11-02 11:22  笑眼望世界  阅读(1252)  评论(0编辑  收藏  举报