Remember a Centos7 Nexus configuration private server (Maven private server)

The first part of environment construction

For details, please see: https://blog.csdn.net/llwy1428/article/details/99537867

Part 2 Nexus configuration

1. Warehouse creation and release of private Jar package to local warehouse

1. Create a warehouse

2. Create a host warehouse

Description:

group: Warehouse group, the warehouse directly referenced by the project;

hosted: The warehouse created by the project itself, upload the jar package by itself, the default has a development library (used in the development stage) and online warehouse (used when the project is online);

proxy: remote reference warehouse.

3. Create release warehouse, warehouse name hunter-release (name customized), type selection: release

4. Create snapshot warehouse, warehouse name hunter-snapshot (name custom), type selection: snapshot

5. Create results

Description:

maven-central: maven central library, pull the jar from https://repo1.maven.org/maven2/ by default

maven-releases: private library release jar (used when online)

maven-snapshots: private library snapshots (debug version, used during development) jar

maven-public: Warehouse grouping, combining the above three warehouses to provide external services, and use them in the local maven basic configuration settings.xml.

6. Configure the local Maven settings.xml configuration file and add the following information:

code show as below

<server>
    <id>hunter-realease</id>
    <username>admin</username>
    <password>admin123</password>
</server>
<server>
    <id>hunter-snapshot</id>
    <username>admin</username>
    <password>admin123</password>
</server>

7. Basic configuration

(1) Configure JDK1.8 in IDEA (omitted);

(2) Configure Maven in IDEA (omitted);

(3) Open IDEA to create a project (project creation process: omitted).

8. Configure the pom.xml file of the project

    <distributionManagement>
        <repository>
            <id>hunter-release</id>
            <name>Release Repository of Hunter</name>
            <url>http://192.168.11.16:8081/repository/hunter-release/</url>
        </repository>
        <snapshotRepository>
            <id>hunter-snapshot</id>
            <name>Snapshot Repository of Hunter</name>
            <url>http://192.168.11.16:8081/repository/hunter-snapshot/</url>
        </snapshotRepository>
    </distributionManagement>

Note: The id in <distributionManagement></distributionManagement> must correspond to the id configured in the server in Maven settings.xml.

8. Write test tool classes, package and publish to local warehouse

After writing the code, execute 1 (clean) and then execute 2 (deploy), as shown on the right side of the figure below:

/**
 * String 工具类
 */
public class HunterStringUtil {
    /**
     * 如果被判断的值是 null 则返回指定的字符串
     * @param obj
     * @param str
     * @return String
     */
    public static String emptyToString(Object obj,String str){
        return obj==null?"":obj.toString();
    }
}

Results of the

9. Now go to Nexus web to view the local warehouse

At this point, the local project is packaged and released to the local warehouse, and the operation is complete!

Second, create remote warehouses, warehouse groups and their use

1. Create Alibaba Cloud remote warehouse

Create result

2. Create a custom warehouse group (add all warehouses to the custom warehouse group-can choose independently)

Create result

3. Test the local warehouse group

Open IDEA to create a project (project creation process: omitted)

Configure the pom.xml file of the project

    <repositories>
        <repository>
            <id>nexus-admin</id>
            <name>nexus-admin Repository</name>
            <url>http://192.168.11.16:8081/repository/nexus-admin/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>nexus-admin</id>
            <name>nexus-admin Repositories</name>
            <url>http://192.168.11.16:8081/repository/nexus-admin/</url>
        </pluginRepository>
    </pluginRepositories>

4. Create a test class

It can be seen that the jar package in the local warehouse can be automatically referenced in the project.

Create a custom warehouse group and reference the jar package uploaded to the local warehouse in the project. The operation is complete!

 

 

At this point, some private server configuration operations of Nexus are complete! There may be supplements later!

Hope it can help you!

 

Reference address:

https://blog.csdn.net/u012637358/article/details/93832491

Guess you like

Origin blog.csdn.net/llwy1428/article/details/105084057