(三)Maven settings.xml 文件配置
程序员文章站
2022-06-06 16:14:13
...
一、基于私服的配置
<?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/MyLocalRepository</localRepository>
<servers>
<server>
<!-- 发布版本 -->
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<!-- 快照版本 -->
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<!-- 配置私服 或者 镜像 -->
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>nexus</name>
<url>http://localhost:8802/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<!-- profile 的id-->
<id>nexus</id>
<repositories>
<repository>
<!-- 仓库id,repositories 可以配置多个仓库,保证id不重复 -->
<id>central</id>
<name>Nexus</name>
<!-- 仓库地址,即nexus仓库组的地址 -->
<url>http://localhost:8802/nexus/content/groups/public/</url>
<!-- 是否下载releases构件-->
<releases><enabled>true</enabled></releases>
<!-- 是否下载snapshots构件-->
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<!--插件仓库,maven的运行依赖插件,也需要从私服下载-->
<id>central</id>
<name>Nexus</name>
<!--插件仓库的id不允许重复,如果重复后边配置会覆盖前边-->
<url>http://localhost:8802/nexus/content/groups/public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- **配置 上面的 nexus-->
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
二、项目POM文件配置
上传时与settings 相对应的配置。
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8802/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8802/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>