preface
maven private server is similar net package server
Official website / version charge
First, make complaints about the slow down of the official website.
Address: https://www.sonatype.com/
Download address: https://www.sonatype.com/download-nexus-repo-oss
Version / charge / free: there are two versions of Nexus Repository Manager warehouse management, the professional version and the oss version. The oss version is free and the professional version is charged. We use the oss version.
Introduction
nexus is a powerful maven warehouse manager, which greatly simplifies the maintenance of local internal warehouses and access to external warehouses
nexus is an out of the box system. It does not need a database. It uses file system and Lucene to organize data
nexus uses ExtJS to develop the interface and Restlet to provide complete REST APIs, which can be used through the integration of IDEA and Eclipse
nexus supports webDAV and LDAP security authentication
nexus provides powerful warehouse management function and component search function. It is based on REST. Its friendly UI is an extjs REST client, occupies less memory, and is based on a simple file system rather than a database
Why
- Save Internet bandwidth.
- Accelerate Maven build.
- Deploy third-party artifacts.
- Improve stability and control.
- Reduce the load of central warehouse.
- Control and audit
- Establish local internal public warehouse
Workflow of private server warehouse
Nexus warehouse type introduction
hosted, a local warehouse. Usually, we will deploy our own components to this type of warehouse. For example, the company's second-party library.
Proxy, proxy warehouse, they are used to proxy remote public warehouses, such as maven central warehouse.
Group, warehouse group, is used to merge multiple hosted/proxy warehouses. When your project wants to use resources in multiple repositories, you don't need to reference multiple times. You only need to reference one group.
Manage local warehouse
We mentioned earlier that the hosted type is a local warehouse. Nexus predefined three local warehouses, namely releases, snapshots and 3rd party Tell us what the three preset warehouses are used for:
Releases: Here we store the builds released in our own projects, usually the Release version. For example, we have built an FTP Server project, and the generated component is ftpserver War, we can Release this build to the Nexus releases local repository The issue of compliance will be introduced later
Snapshots: this warehouse is very useful. Its purpose is to allow us to release non release versions and unstable versions. For example, we develop a project under trunk. Before the formal release, you may need to temporarily release a version to your peers, because your peers are relying on your module development, At this time, we can release the Snapshot version to the warehouse, and your companions can obtain and use the temporary version through simple commands
3rd Party: as the name suggests, a third-party library. You may ask whether there is a central warehouse to manage the third-party library. Yes, here means that you can add your own third-party library. For example, some components do not exist in the central warehouse For example, if you can't find the JDBC driver of Oracle in the central warehouse, we need to add it to the 3rdparty warehouse ourselves.
Installing Nexus on Windows
The version I installed
Official installation documentation: https://help.sonatype.com/repomanager3/installation/installation-methods
Installation free, download it, unzip it and run it directly.
1. Decompression
2. Configure environment variables
3. Just run it
Command set: start, stop, restart, force reload
4. Calibration
Open http://localhost:8081/
The following interface appears. The default account and password are admin/admin123
Some versions (passwords) will be put in a folder: they must be modified after login
Configure Nexus
1. Basic configuration
Description of Repositories used by Maven:
maven central: maven Central Library, from https://repo1.maven.org/maven2/ Pull jar
Maven releases: private library distribution jar
Maven snapshots: private library snapshot (debug version) jar
maven public: warehouse grouping, combining the above three warehouses to provide external services, and configuring settings on the basis of local maven Used in XML.
If it is not enough, you can also select and create the warehouse according to the warehouse type above the blog post.
2. If a third-party agent is required, the configuration is as follows:
If the proxy warehouse or hosted warehouse is created, it needs to be added to the public warehouse.
1. to configure
2.
3.
4. Configure private server in maven and edit setting xml
<servers> <server> <!--This is server of id(Note that the user is not logged in id),Should id And distributionManagement in repository Elemental id Match. --> <id>nexus</id> <username>admin</username> <password>admin123</password> </server> </servers> <!--The list of downloaded images configured for the warehouse list. --> <mirrors> <mirror> <!--Unique identifier of the mirror. id Used to distinguish between different mirror Element. --> <id>nexus</id> <!--All builds configured here are downloaded from the private repository *For all, you can also write central --> <mirrorOf>*</mirrorOf> <name>central repository</name> <!--Of the mirror URL. Building the system will give priority to the use of this URL,Instead of using the default server URL. --> <url>http://127.0.0.1:8081/repository/maven-public/</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <!--Remote warehouse list, which is Maven Used to populate a set of remote projects used to build the local repository of the system. --> <repositories> <!--Release version warehouse--> <repository> <id>nexus</id> <!--the address is nexus in repository(Releases/Snapshots)Corresponding address in--> <url>http://127.0.0.1:8081/repository/maven-public/</url> <!--true perhaps false Indicates whether the warehouse is enabled for downloading certain types of components (release version, snapshot version). --> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <!--Activate configuration--> <activeProfiles> <!--profile Lower id--> <activeProfile>nexus</activeProfile> </activeProfiles>
Upload the jar to nexus from the command line:
mvn deploy:deploy-file -DgroupId=com.sgcc.ams -DartifactId=ams-base -Dversion=1.7.0 -Dpackaging=jar -Dfile=C:\develop\lib\ams-base-1.7.0.jar -Durl=http://127.0.0.1:8081/repository/maven-releases/ -DrepositoryId=nexus
Configure the private server in the project, POM Add to XML
<!--Upload to nexus In the warehouse, cooperate mvn deploy:deploy--> <distributionManagement> <repository> <!--there id Need and settings.xml Medium server of id agreement --> <id>nexus-release</id> <name>Nexus release Repository</name> <!--releases Warehouse --> <url>http://127.0.0.1:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus snapshots Repository</name> <!--snapshots Warehouse --> <url>http://127.0.0.1:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>