官方文档是好东西
http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Super_POM
http://maven.apache.org/guides/mini/guide-multiple-repositories.html
一、前言
maven配置的加载顺序为:
项目pom.xml ->
.m2/setting.xml ->
maven_dir/conf/setting.xml ->
超级POM:pom-4.0.0.xml
(其中最后一个为maven安装路径下的包里自带的,一般用户不会去修改。里面配置了中央仓库的地址。)
路径在maven安装路径下lib下maven-model-builder-3.6.3的jar包里,用解压软件打开后在如下位置
二、配置项说明
如果要更改默认maven中央仓库地址,可在上面三个文件中配置。
mirror是镜像,一般是用来替换中央仓库的。
repository是仓库,直接下载jar包的地址
repository的搜索优先级高于mirror。
如果不需要更改中央仓库,只需要在settings,xml或者pom.xml中配置repository就可以了。至于在哪里配置,要看是常用的通用的,还是本项目特殊的。
poem内多个repository的设置格式为:
<project>
...
<repositories>
<repository>
<id>my-repo1</id>
<name>your custom repo</name>
<url>http://jarsm2.dyndns.dk</url>
</repository>
<repository>
<id>my-repo2</id>
<name>your custom repo</name>
<url>http://jarsm2.dyndns.dk</url>
</repository>
</repositories>
...
</project>
setting内需要这么设置
<settings>
...
<profiles>
...
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>my-repo2</id>
<name>your custom repo</name>
<url>http://jarsm2.dyndns.dk</url>
</repository>
</repositories>
</profile>
...
</profiles>
<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>
...
</settings>
Repository Order
Remote repository URLs are queried in the following order for artifacts until one returns a valid result:
- Global
settings.xml
- User
settings.xml
- Local POM
- Parent POMs, recursively
- Super POM
(未完待续)