配置文件docker-compose.yml
version: '3.1'
services:
nexus:
restart: always
image: sonatype/nexus3
container_name: nexus
ports:
- 80:8081
volumes:
- /usr/local/docker/nexus/data:/nexus-data
默认账户密码
admin
admin123
maven目录的settings.xml
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
配置自动化部署
项目的pom文件
增加
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://192.168.1.22:80/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.1.22:80/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
注意:这里的id与settings的id须一致
部署到私服
忽略测试的部署
mvn deploy -Dmaven.test.skip=true
上传第三方 JAR 包
mvn deploy:deploy-file -DgroupId=com.google.code.kaptcha -DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar -Dfile=D:ChromeDownloadkaptcha-2.3.jar -Durl=http://192.168.1.22/repository/maven-releases/ -DrepositoryId=nexus-releases
配置代理仓库
<repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://192.168.1.22:80/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus Plugin Repository</name>
<url>http://192.168.1.22:80/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>