2017年9月20日 | 1 Comment 问题: 如何搭建 Maven 私服 解决: 发布jar 流程 docker run -d -p 8081:8081 --name nexus nexus/nexus3 。启动后访问 http://localhost:8081 查看管理界面账户 admin 密码 admin123 发布jar 到nexus 需要配置 pom.xml 中的 <distributionManagement> <repository> <id>mynexus</id> <name>myNexus</name> <url>http://localhost:32768/repository/mynexus/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://localhost:32768/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> 123456789101112 <distributionManagement> <repository> <id>mynexus</id> <name>myNexus</name> <url>http://localhost:32768/repository/mynexus/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://localhost:32768/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> 发布前还需要配置 ~/.m2/settings.xml <?xml version="1.0" encoding="UTF-8" ?> <settings> ... <servers> <server> <id>mynexus</id> <username>admin</username> <password>admin123</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers> ... </settings> 1234567891011121314151617 <?xml version="1.0" encoding="UTF-8" ?><settings>... <servers> <server> <id>mynexus</id> <username>admin</username> <password>admin123</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers>...</settings> 执行 mvn clean deploy 发布SNAPSHOT到nexus 使用: pom.xml 增加dependency 后还增加 <repositories> <repository> <id>mynexus</id> <url>http://localhost:32768/repository/maven-snapshots/</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> 123456789 <repositories> <repository> <id>mynexus</id> <url>http://localhost:32768/repository/maven-snapshots/</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> 参考: 《Maven实战》 http://aijezdm915.iteye.com/blog/1335025
docker run -d –name nexus2 -p 8081:8081 -p 8082:8082 -p 8083:8083 -v /home/nexus/nexus-data:/nexus-data sonatype/nexus3 回复