Nexus3 use

A, Nexus Introduction

nexusIs a powerful mavenrepository manager (PW), which greatly simplifies maintenance and access to external warehouse inside the local warehouse.

①Nexus Features

  • Save external network bandwidth.
  • Accelerate the Mavenbuilding.
  • 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

  • hostedLocal 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 as mavena central warehouse.
  • group, Storage group, to combine multiple hosted/proxywarehouses, if you want more items repositorywhen you do not need to use the resources referenced multiple times, only a reference groupto.

③Nexus installation and presentation

After decompression have two folders download good: nexusand sonatype-work. The former is a function of the realization, which is responsible for storing data.

Enter nexusthe bindirectory: Start ( nexus.exe /run), after starting the visit http://localhost:8081/, click Browsecan see the four default warehouse
Nexus 4 built warehouse

Description :

maven-central: mavenCentral 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 mavenbasic configuration settings.xmlin 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 jarpackage requires authentication, modify the Mavenconfiguration file settings.xmlin the serversconfiguration 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 releasetype jarpackage, a deployment snapshottype jarpackage. idUsed to uniquely specify an authentication with information, to be followed in pomuse.

In Maventhe project pomadd files distributionManagementtag, which is responsible for describing maven deployupload 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>

URLFrom here you copy the graphical interface, idthat is just in Maventhe user profile configuration information, namecan freely
Copy URL

Execution mvn clean deploycan see uploaded in the warehouse jarpack.

② pulling jar package

Pull jarpackage requires Maventhe project pomto add file repositoriestags:

<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>
Published 81 original articles · won praise 124 · views 380 000 +

Guess you like

Origin blog.csdn.net/qq_38697437/article/details/103157433