5. Nexus私有仓库
环境:
Ubuntu16.04
docker
docker-compose
创建容器
docker-compose.yml
version: '3.1' services: nexus: restart: always image: sonatype/nexus3 container_name: nexus ports: - 8081:8081 volumes: - /usr/local/docker/nexus/data:/nexus-data
建立容器:
docker-compose up -d
访问 192.168.91.131:8081
复制登录密码:
docker exec -it 容器id bash cd /opt/sonatype/sonatype-work/nexus3/ cat admin.password
登录修改密码为 admin123
配置认证信息
在maven 的settings.xml中添加Nexus认证信息(在servers节点下)
<server> <id>nexus-releases</id> <username>admin</username> <password>123456</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>123456</password> </server>
在pom当中添加如下代码:
<distributionManagement> <repository> <id>nexus-releases</id> <name>Nexus Release Repository</name> <url>http://192.168.91.131:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://192.168.91.131:8081/repository/maven-snapshots/</url> </snapshotRepository > </distributionManagement>
部署到仓库
mvn deploy
上传第三方jar包
mvn deploy:deploy-file -DgroupId=com.google.code.kaptcha -DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar -Dfile=D:\kaptcha-2.3.jar -Durl=http://192.168.91.131:8081/repository/maven-releases/ -DrepositoryId=nexus-releases
配置代理仓库
<repositories> <repository> <id>nexus</id> <name>Nexus Repository</name> <url>http://192.168.91.131:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>Nexus Plugin Repository</name> <url>http://192.168.91.131:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories>