1.修改settings.xml文件,以下配置既可以访问公网阿里云也可以访问私服
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:\Program Files\apache-maven-3.6.0\repo</localRepository>
<servers>
<server>
<id>my_nexus_release</id>
<username>deployment</username>
<password>deploymentxxx</password>
</server>
<server>
<id>my_nexus_snapshots</id>
<username>deployment</username>
<password>deploymentxxx</password>
</server>
</servers>
<profiles>
<profile>
<id>my_nexus</id>
<repositories>
<repository>
<id>my_nexus</id>
<url>http://ip地址:端口号/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>my_nexus</id>
<url>http://ip地址:端口号/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- 激活 -->
<activeProfiles>
<activeProfile>my_nexus</activeProfile>
</activeProfiles>
</settings>
2.Servers的配置,配置了私服的用户名和密码和项目中的pom的以下配置配合使用
注意:id保持一致
<distributionManagement>
<repository>
<id>my_nexus_release</id>
<name>my_nexus Release Repository</name>
<url>http://ip地址:端口号/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>my_nexus_snapshots</id>
<name>my_nexus Snapshot Repository</name>
<url>http://ip地址:端口号/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>