Nexus私服和Maven集成,集成的方式:代理中央倉庫、Snapshot包的管理、Release包的管理、第三方Jar上傳到Nexus上。maven
1.代理中央倉庫,在pom文件中配置私服的地址url
<repositories> <repository> <id>maven-public</id> <url>http://127.0.0.1:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories>
2.Snapshot、Releases包的管理spa
1)修改Maven的settings.xml文件,加入認證機制代理
<servers> <server> <id>nexus</id> <username>admin</username> <password>admin123</password> </server> </servers>
2)修改工程的Pom文件code
<distributionManagement> <repository> <id>maven-releases</id> <name>maven-releases</name> <url>http://127.0.0.1:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>maven-snapshots</id> <name>maven-snapshots</name> <url>http://127.0.0.1:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
3)使用mvn deploy 命令將jar包發佈到私庫。server
3.將第三方jar上傳到私服xml
mvn deploy:deploy-file -DgroupId=com.nexus.test -DartifactId=nexus-test -Dversion=1.0.0 -Dpackaging=jar -DrepositoryId=nexus -Dfile=F:\nexus-test-1.0.0.jar -Durl=http://127.0.0.1:8081/repository/maven-releases/-DgeneratePom=false
注意事項:it
-DrepositoryId=nexus 對應的就是Maven中settings.xml的認證配的名字。io