@TOC


Recommend personal Docker articles, very detailed

【 Docker container 1】Dockerd details and installation



Build Jdk, Mysql, Nginx, Redis, Tomcat environment based on Docker in one minute



Deploy the SpringBoot project based on Docker



【 Docker container 4】 Build Docker private server based on Docker, and how to use Docker private server details



How to build Maven private server based on Docker, and how to use Maven private server



Build GitLab management code based on Docker



Automatic construction, deployment, testing and monitoring of projects based on Docker installation Jenkins



1. What is the Nexus

Nexus is a powerful Maven repository manager that greatly simplifies maintenance of its own internal repositories and access to external repositories. With Nexus you can have complete control over accessing and deploying each Artifact in your maintained repository in only one place. We can set up a Maven private server on a local area network to deploy third party common artifacts or act as a proxy for remote repositories on the local network.

2.Nexus and Maven private server principles

Explanation: Nexus is Maven’s private repository, and most large companies have their own private Maven repository

1. From the actual development of the project, we can see some components (customized components, not open source) that can not be downloaded from the external warehouse, such as internal projects need to use, so that we can be deployed to the private server, so that other dependent projects can use.

2, in order to save bandwidth and time, set up a private warehouse server in the LAN, with its proxy all external remote warehouse. When the local Maven project needs to download components, it first requests the private server. If the private server does not have any components, it then requests the remote repository. After downloading components from the remote repository, the components are cached on the private server. In this way, even if there is no Internet connection for the time being, the whole project can still be used normally because the private server has cached a large number of components. At the same time, it also reduces the load of the central warehouse.

3. What scenarios will you use Maven private server for?

1. In actual development, third-party JARS and internal communication service interfaces that may be used in the project will be entered into the private server of the company.

2. Custom JAR packages, or SpringBoot POM packages, some packages packaged in private Maven, only for yourself or your friends to use (for example, you packaged a very powerful code automatic generator, or wechat and Alipay payment package, only need a little configuration can be used, Next time, you can configure the coordinates in a POM or XML file for yourself, your company or your friends.)

4. Build Nexus based on Docker to build Maven private server

1. Download the Nexus3 image

Be sure to build a Docker Linux environment yo, don’t know can see my previous position

Enter: docker pull sonatype/ Nexus3Copy the code

2. Start a container using the image

Note: Mount /var/nexus-data to /root/nexus-data Docker run -d -p 8081:8081--name nexus -v Docker run -d -p 8081:8081--name nexus -v /root/nexus-data:/var/nexus-data --restart=always sonatype/nexus3Copy the code

3. Log in to the Maven private server

Close the firewall and go to http://ip:8081 Maven private server to start the container. It takes a while.

Note: The default account password is admin/ Admin123

Damn, I can’t get in. Just change the password

4. Change the initial password and log in to the Maven private server

If the user name or password is incorrect, go to the admin.password file to see the initial password.

Enter :(find password file) find / -name 'admin.password'Copy the code

Enter: cat Enter the file location looked up above to get the passwordCopy the code

That jumble is the code. Then his login to change the password to log in again, after logging in, he will let you change the user name and password by default, note that both are typed new passwordJust go to the next step

5. Create Maven private server

1. Create the Maven repository

Click create in blue and it’s ok

2. Create a Maven repository

Go to the Settings screen, select Repositories, and click Create Repository, as shown below:Select the repository type. Maven has three types: Group, Hosted, and Proxy. Only the Hosted type is demonstrated here, so choose Maven(Hosted), as shown below:This is the right warehouseEnter name, select Storage, move to the bottom and select CreateAppear as shown in figureWhy is the underground Docker so slow different? Docker was created before

6. Upload the Java project build JAR package to Maven private server

1. Modify local settings. XML

Find settings.xml using idea

2. Open it to find setting.xml

Add your Maven private server username and password to the Server TABIt’s possible that this file has a lot of comments, just ignore them, I didn’t screen them

3. Configure the POM file for the project

Add to poM

<! --> <! <distributionManagement> <repository> <! M2 /settings. XML --> < ID >boot-tool</ ID > <! - the location of the uploaded - > < url > http://120.77.0.58:8081/repository/boot-tool/ < / url > < / repository > < / distributionManagement > < build > <plugins> <! Plugins </groupId> <artifactId> Maven-deploy-plugin </artifactId> The < version > 2.7 < / version > < / plugin > <! Plugins </groupId> <artifactId>maven-source plugin</artifactId> <version>2.2.1</version> <execution> <phase>package</phase> < Goals > <goal>jar</goal> </execution> </executions> </plugin> </plugins> </build>Copy the code

Change the upload location to the private Maven repository location:

4. Pack and upload

Click Terminai under Ider

Enter MVN deploy

Wait a while and upload successfully Page to visit their upload location to see Has been successfully

7. Test using jars from Maven private server

How do I reference that I created an empty Maven project here

Compare the two images, just in the POM file class to put the name, ID, version corresponding, in reference to the remote repository address can be used code

<dependencies> <dependency> <groupId>com.lijie</groupId> <artifactId>lijie-core-boot</artifactId> <version>2.0</version>  </dependency> </dependencies> <repositories> <repository> <id>mayikt</id> The < url > http://120.77.0.58:8081/repository/boot-tool/ < / url > < / repository > < / repositories >Copy the code

This is the JAR package I introduced