Article Directory
A, Nexus Introduction
nexus
Is a powerful maven
repository manager (PW), which greatly simplifies maintenance and access to external warehouse inside the local warehouse.
①Nexus Features
- Save external network bandwidth.
- Accelerate the
Maven
building. - The deployment of third-party components.
- Improve stability, enhanced control.
- Reducing the load on the central warehouse.
- Control and audit
- The establishment of local internal public warehouse
②Nexus warehouse type
hosted
Local warehouse, Normally we would deploy its own members to this type of warehouse. For example, the company's second party libraries.proxy
, Acting warehouse, they are used to proxy remote public repository, such asmaven
a central warehouse.group
, Storage group, to combine multiplehosted/proxy
warehouses, if you want more itemsrepository
when you do not need to use the resources referenced multiple times, only a referencegroup
to.
③Nexus installation and presentation
After decompression have two folders download good: nexus
and sonatype-work
. The former is a function of the realization, which is responsible for storing data.
Enter nexus
the bin
directory: Start ( nexus.exe /run
), after starting the visit http://localhost:8081/
, click Browse
can see the four default warehouse
Description :
maven-central
: maven
Central library, the default from the https://repo1.maven.org/maven2/
pulljar
maven-releases
: Private library releasejar
maven-snapshots
: Snapshot private library (debug version)jar
maven-public
: Warehouse group, the top three warehouses together to provide services in the local maven
basic configuration settings.xml
in use.
If not enough, you can also choose to create a warehouse in accordance with the above types.
Two, Maven and Nexus combination
① upload jar package
Upload jar
package requires authentication, modify the Maven
configuration file settings.xml
in the servers
configuration tag:
<servers>
<server>
<id>release_user</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshot_user</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
Here two user configuration, a deployment release
type jar
package, a deployment snapshot
type jar
package. id
Used to uniquely specify an authentication with information, to be followed in pom
use.
In Maven
the project pom
add files distributionManagement
tag, which is responsible for describing maven deploy
upload remote repository:
<distributionManagement>
<repository>
<id>release_user</id>
<name>Release Deploy</name>
<url>http://localhost:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshot_user</id>
<name>Snapshot Deploy</name>
<url>http://localhost:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
URL
From here you copy the graphical interface, id
that is just in Maven
the user profile configuration information, name
can freely
Execution mvn clean deploy
can see uploaded in the warehouse jar
pack.
② pulling jar package
Pull jar
package requires Maven
the project pom
to add file repositories
tags:
<repositories>
<repository>
<id>nexus-public</id>
<name>Nexus Public</name>
<url>http://localhost:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>