maven multi warehouse configuration company warehouse and Ali warehouse

Keywords: Java Maven nexus xml

For the company's intranet private server warehouse, the private server warehouse cannot access the Internet. At this time, the private server warehouse cannot act as an agent for Alibaba's maven warehouse. Our maven needs to configure multiple warehouses:

conf/settings.xml configuration file in maven Directory:

1. Create a new profile in the profiles tab, and configure a company's warehouse and Ali's warehouse;

    <profile>
<id>nexus</id> <repositories> <repository> <id>maven-releases</id> <url>http://192.168.0.54:8899/ajco/repository/maven-releases/</url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> <repository> <id>maven-snapshots</id> <url>http://192.168.0.54:8899/ajco/repository/maven-snapshots/</url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>maven-releases</id> <url>http://192.168.0.54:8899/ajco/repository/maven-releases/</url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </pluginRepository> <pluginRepository> <id>maven-snapshots</id> <url>http://192.168.0.54:8899/ajco/repository/maven-snapshots/</url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </pluginRepository> </pluginRepositories> </profile> <profile> <id>aliyun</id> <repositories> <repository> <id>central</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </pluginRepository> </pluginRepositories> </profile>

 

2. Configure the active profile in the active profiles tab to activate the above warehouse. The value in the active profile corresponds to the id value in the above profile

    <activeProfile>nexus</activeProfile>
    <activeProfile>aliyun</activeProfile>

 

Description:

1. If aliyun warehouse id is set to central, the default remote warehouse in maven will be overwritten.

Aliyun's warehouse can also be configured without configuration. You can directly configure a mirror warehouse in the mirrors tab. If the mirrorOf value of the mirror warehouse is set to central, you can also overwrite the default warehouse

      <mirror>
          <id>alimaven</id>
          <mirrorOf>central</mirrorOf>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
      </mirror>

 

To configure maven deploy:

1. Create a new server tag in the servers tag to define the account password configuration of a login private server;

    <server>
        <id>deploymentRepo</id>
        <username>repouser</username>
        <password>repopwd</password>
    </server>

 

2. The pom.xml file of the project is added with the following configuration. The id corresponds to the id in the server above, which means that it will be uploaded to the warehouse below when deploy ing, and the account password above will be used;

    <distributionManagement>
        <repository>
            <id>deploymentRepo</id>
            <url>http://192.168.0.54:8899/ajco/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>deploymentRepo</id>
            <url>http://192.168.0.54:8899/ajco/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

Posted by sameveritt on Wed, 04 Dec 2019 08:17:31 -0800