Article Directory
1 installation
1 Enter the installation directory
cd /usr/local/docker/nexus
2 Edit compose file
vi docker-compose.yml
3 Add file content
- Mirror reference URL: https://hub.docker.com/
version: '3'
services:
nexus:
restart: always
image: sonatype/nexus3
container_name: nexus
ports:
- 83:8081
- 443:443
volumes:
- /usr/local/docker/nexus/data:/nexus-data
4 Create a new data volume directory and modify permissions
sudo mkdir data && sudo chmod 777 data
5 Start
docker-compose up -d
6 Enter the container, containerId is the container id
docker exec -it containerId bash
#如果提示bash错误,请用以下命令
docker exec -it containerId sh
7 Check the password for the initial test, the default user name: admin
cat /nexus-data/admin.password
8 Browser accesshttp://192.168.30.143:83
Initialize change password
Enabling anonymous access Allow anonymous access uncheck
2 configuration
2.1 Configure Maven's settings.xml
Refer to the URL for the description of the settings.xml file: https://www.cnblogs.com/wdliu/p/8312543.html
1 Add the following information to the servers node.
ID can be freely specified. The user name and password are the user name and password of the private warehouse.
<server>
<id>maven-nexus-releases</id>
<username>admin</username>
<password>12345678</password>
</server>
<server>
<id>maven-nexus-snapshots</id>
<username>admin</username>
<password>12345678</password>
</server>
2 Add Alibaba Cloud mirroring under the mirrors node to increase download speed
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
3 Insert under the profiles node
</profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>maven-nexus-releases</id>
<url>http://192.168.30.143:83/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>maven-nexus-snapshots</id>
<url>http://192.168.30.143:83/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven-nexus-releases</id>
<url>http://192.168.30.143:83/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
<pluginRepository>
<id>maven-nexus-snapshots</id>
<url>http://192.168.30.143:83/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
2.2 Configure project pom.xml
1 Download the jar package from the warehouse and add content
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://192.168.30.143:83/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus</name>
<url>http://192.168.30.143:83/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
2 Realize uploading the local jar package
<distributionManagement>
<repository>
<id>maven-nexus-releases</id>
<url>http://192.168.30.143:83/repository/maven-releases</url>
</repository>
<snapshotRepository>
<id>maven-nexus-snapshots</id>
<url>http://192.168.30.143:83/repository/maven-snapshots</url>
</snapshotRepository>
</distributionManagement>
3 Verify upload
1 You can manually upload the jar in the cmd window, as follows:
mvn deploy:deploy-file -DgroupId=org.springframework.boot -DartifactId=spring-boot-starter -Dversion=1.4.7 -Dpacking=jar -Dfile=D:/spring-boot-1.4.7.RELEASE.jar -Durl http://192.168.30.143:83/repository/maven-releases/ -DrepositoryId=maven-nexus-releases