通过dos检测道maven安装成功后,在maven的conf目录下修改settings.xml文件中的国内镜像时,执行mvn help:system命令时出错,原因在于url地址出错,如下我网上找到的阿里云镜像:
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
原因在于url地址中最后的/,将其删除保存即可,如下
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
然后重启dos,再次执行mvn help:system,
等待片刻,看到下图中显示的BUILD SUCCESS字样,即代表更换国内镜像成功
还有个问题需注意下,上面成功后,在idea里maven还遇到错误:
Maven:sun.security.validator.ValidatorException: PKIX path building failed
这个是 HTTPS 的证书安全检查问题,最简单的方式是忽略SSL的证书检查,在 maven 打包命令中加上参数-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
,如下图
我记得还有个问题是IDEA和Maven的版本兼容问题,忘记了,你们注意一下
这里放上我的setting.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>E:\Maven\maven-repository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<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>
</settings>
还有关键信息截图也放上来