maven setting 配置
<?xml version="1.0" encoding="UTF-8"?> <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>D:\maven\repositorylocalRepository> <servers> <server> <id>nexusid> <username>adminusername> <password>xxxxpassword> server> servers> <mirrors> <mirror> <id>central-proxyid> <mirrorOf>centralmirrorOf> <url>https://xxxxurl> mirror> mirrors> <profiles> <profile> <id>mycofid> <repositories> <repository> <id>nexusid> <name>my's nexusname> <releases> <enabled>trueenabled> releases> <snapshots> <enabled>trueenabled> snapshots> <url>http://xxx/groups/publicurl> repository> repositories> <pluginRepositories> <pluginRepository> <id>nexusid> <url>http://xxxx/groups/publicurl> <releases> <enabled>trueenabled> releases> <snapshots> <enabled>trueenabled> snapshots> pluginRepository> pluginRepositories> profile> profiles> 激活profile--> <activeProfiles> <activeProfile>mycofactiveProfile> activeProfiles> settings>
当构建一个Maven项目时,首先检查pom.xml文件以确定依赖包的下载位置,执行顺序如下:
1、从本地资源库中查找并获得依赖包,如果没有,执行第2步。
2、如果在pom.xml中定义了自定义的远程仓库,那么也会在这里的仓库中进行查找并获得依赖包,如果没有,执行第3步。
3、从Maven默认中央仓库中查找并获得依赖包(https://repo1.maven.org/maven2/),如果都没有找到,那么Maven就会抛出异常。
默认中央仓库的地址:
1、http://repo1.maven.org/maven2/
默认的中央仓库id为【central】, setting中<mirrorOf>centralmirrorOf>表示不再从默认中央仓库中获取jar,一般为公司私服地址。
2、profiles 设置表示:设置一个指定的存储库地址。下载顺序为: 本地库->profiles地址->中央仓库【有mirrorOf则从mirror地址下载,不会再查询默认的中央仓库】
配置server:
是向私服上传jar时使用,id 一 一对应,项目中需要在pom.xml中配置如下
<distributionManagement> <repository> <id>nexusid> <name>releasesname> <url>http://xxx/content/repositories/releasesurl> repository> <snapshotRepository> <id>nexusid> <name>snapshotsname> <url>http://xxx/content/repositories/snapshotsurl> snapshotRepository> distributionManagement>