Private server is a special remote warehouse, which is a warehouse service set up in a local area network. The private server acts as a remote warehouse on the WAN for use by Maven users in the local area network. When Maven needs to download the use of the build, it first requests it from the private server. If it is not available on the private server, it downloads it from an external remote warehouse, then caches it on the private server, and then provides services for the Maven download request.
In maven, configure setting.xml, and then use the mvn deploy command to transfer the package to the private server
For some third-party jar packages, we generally need to upload them through a new warehouse
<servers> <server> <id>nexus</id> <username>gaming</username> <password>gaming</password> </server> </servers>
<distributionManagement> <repository> <id>nexus</id> <name>releases Repository</name> <url>http://192.168.1.222/repository/gaming/</url> </repository> </distributionManagement>
1. It is easier to maintain your own maven private server, and it is faster for company development to move out of the jar from the maven private server to the local warehouse
2. Some companies have not opened the external network to developers
Log in to the nexus backend and choose to create a repository
proxy : is the proxy of the remote warehouse. For example, a proxy of a central repository is configured in nexus. When a user requests an artifact from this proxy, the proxy will first look up locally. If it can’t be found, it will download it from the remote repository and return it to the user. It serves as a relay; Hosted : It is the host warehouse. Users can deploy some of their own components to hosted, or manually upload components to hosted. For example, the oracle driver, ojdbc6.jar, is not available in the central repository and needs to be manually uploaded to hosted; Group : It is a warehouse group, which does not have this concept in maven, and is unique to nexus. The purpose is to aggregate the above-mentioned multiple warehouses and expose a unified address to users, so that users do not need to configure multiple addresses in the pom, as long as the group address is configured uniformly, the Repository Path on the right can be clicked in and you can see the warehouse. A list of artifacts. But pay attention to browser caching.
Select maven2 (hosted)
Customize the warehouse name, and use the default for the rest
After that, the upload is successful, which is uploaded in the background
You can also upload by command
mvn deploy:deploy-file -DgroupId=net.sf -DartifactId=json-lib -Dversion=2.4 -Dpackaging=jar -Dfile=E:/json-lib-2.4.jar -Durl=http://192.168.1.222/nexus/repository/releases/-DrepositoryId=releases
Download, need to modify the setting.xml of maven
Set up the repository
Reimport can be done afterwards.