Maven私服的使用

xiaoxiao2021-02-28  98

本地项目配置引用私服

一. 自动发布构件到远程仓库  1. 在工程的pom.xml中添加:

<distributionManagement> <repository> <id>releases</id><!--这个ID需要与你的release仓库的Repository ID一致--> <url>http://172.18.19.157:8081/nexus/content/repositories/releases</url> </repository> <snapshotRepository> <id>snapshots</id><!--这个ID需要与你的snapshots仓库的Repository ID一致--> <url>http://172.18.19.157:8081/nexus/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement> 123456789101112 123456789101112

2.修改$MAVEN_HOME\conf目录下的settings.xml配置文件,添加如下配置:

<servers> <server> <id>releases</id> <username>admin</username> <password>dev123</password> </server> <server> <id>snapshots</id> <username>admin</username> <password>dev123</password> </server> </servers> 123456789101112 123456789101112

3.打开windows命令行,在工程所在目录下执行

mvn deploy 1 1

所部署的包就自动上传到了nexus安装目录下的 

二.配置Maven从Nexus下载构件  1.在POM中配置Nexus私服,这样的配置只对当前的Maven项目有效。

<repositories> <repository> <id>public</id> <name>Team Maven Repository</name> <url>http://172.18.19.157:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> 12345678910111213 12345678910111213

2.在settings.xml中配置profile元素,这样就能让本机所有的Maven项目都使用自己的Maven私服。

转载请注明原文地址: https://www.6miu.com/read-69566.html

最新回复(0)