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;

<id>nexus</id> <repositories> <repository> <id>maven-releases</id> <url></url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> <repository> <id>maven-snapshots</id> <url></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></url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </pluginRepository> <pluginRepository> <id>maven-snapshots</id> <url></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></url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url></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




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

          <name>aliyun maven</name>


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;



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;


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