1.setting.xml配置的公网的maven地址(包括阿里云)
如:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>本机指定目录</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>aliyun-nexus</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<!-- <mirrorOf>nexus-aliyun</mirrorOf>-->
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>maven-nexus</id>
<name>Nexus maven</name>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>nexus-maven</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>mynexus</id>
<repositories>
<repository>
<id>aliyun-nexus</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>maven-nexus</id>
<name>Nexus maven</name>
<url>https://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun-plugin</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>mynexus</activeProfile>
</activeProfiles>
</settings>
2.在公司内,更换setting.xml后,如setting_companyA.xml,通过idea的setting进行操作
更改setting.xml后,
3.出现的现象:
maven无法从公司的私服拉取依赖 ,仍然转向公网去拉取依赖
4.解决方案:
将公司内网的maven配置文件命名为setting.xml,并且放到$MAVEN_HOME%/conf目录下,并且在导入依赖时指定该setting.xml文件中指定的profile