1、maven从nexus下载构件的配置
1.1、在项目pom中配置远程仓库(方式一)
<repositories> <repository> <id>remote</id> <name>my nexus repository</name> <url>http://192.1.1.103:8081/nexus/content/groups /public/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>Nexus</name> <url>http://192.1.1.103:8081/nexus/content/groups /public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories>
1.2、或者在setting.xml中以镜像形式配置远程仓库(方式二)
这样就不需要每个项目都配置一次
<mirrors> <mirror> <id>remote</id> <name>remote</name> <url>http://192.1.1.103:8081/nexus/content/ repositories/central/</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors>
<mirrorOf>*</mirrorOf> 这句话意思是所有构件都会从私服中下载
1.3、或者在setting中配置<profile>标签(方式三)
<profiles> <profile> <id>dev</id> <repositories> <repository> <id>nexus</id> <name>Nexus</name> <url>http://192.1.1.103:8081/nexus/content/groups /public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>public</id> <name>Nexus</name> <url>http://192.1.1.103:8081/nexus/content/groups /public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <!-- 激活私服 -->
<activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>
2、maven部署构件到nexus的配置
2.1、项目pom中配置
<distributionManagement> <repository> <id>releases</id> <name>nexus release</name> <url>http://192.1.1.103:8081/nexus/content/ repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>nexus snapshot</name> <url>http://192.1.1.103:8081/nexus/content/ repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
2.2、setting.xml中配置
<servers> <server> <id>releases</id> <username>deployment</username> <password>deployment123</password> </server> <server> <id>snapshots</id> <username>deployment</username> <password>deployment123</password> </server> </servers>
2.3、maven命令
mvn deploy
本文作者:hjjay
原文出处:https://www.cnblogs.com/jayhou/p/12271566.html
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。