环境: 电脑型号:ThinkPad R480 16G+500G Windows10系统
IDE工具:IntelliJ IDEA 2018.1.5
Java版本:jdk1.8.0_171
Maven版本:apache-maven-3.6.2
问题描述: 设置好Java和Maven环境后,使用idea中的spring initializr构建一个只包含web的demo,下载依赖时出现以下错误:
D:\Java\jdk1.8.0_171\bin\java.exe -Dmaven.multiModuleProjectDirectory=D:\IdeaProjects\demo -Dmaven.home=D:\apache-maven-3.6.2 -Dclassworlds.conf=D:\apache-maven-3.6.2\bin\m2.conf "-javaagent:D:\IntelliJ IDEA 2018.1.5\lib\idea_rt.jar=60044:D:\IntelliJ IDEA 2018.1.5\bin" -Dfile.encoding=UTF-8 -classpath D:\apache-maven-3.6.2\boot\plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version=2018.1.5 clean -f pom.xml
[INFO] Scanning for projects...
Downloading from nexus-aliyun: https://maven.aliyun.com/repository/public/org/springframework/boot/spring-boot-starter-parent/2.2.2.RELEASE/spring-boot-starter-parent-2.2.2.RELEASE.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.example:demo:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.2.RELEASE from/to nexus-aliyun (https://maven.aliyun.com/repository/public): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target and 'parent.relativePath' points at no local POM @ line 5, column 13
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.example:demo:0.0.1-SNAPSHOT (D:\IdeaProjects\demo\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for com.example:demo:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.2.RELEASE from/to nexus-aliyun (https://maven.aliyun.com/repository/public): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target and 'parent.relativePath' points at no local POM @ line 5, column 13 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
Process finished with exit code 1
settings文件配置如下:
<?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:\repository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
<mirror>
<id>central</id>
<mirrorOf>*</mirrorOf>
<name>Maven Repository Switchboard</name>
<url>https://repo1.maven.org/maven2/</url>
</mirror>
</mirrors>
<profiles>
</profiles>
</settings>
百度出的结果是需要信任阿里证书,已添加信任
甚至生成了jssecacerts
文件,修改过maven版本,都没有作用,求大神指教!
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
遇到这个问题,通常是因为Maven在尝试从远程仓库下载依赖时,遇到了SSL证书验证的问题。尽管你已经尝试了添加信任证书,但问题仍然存在,这可能是因为Java的JDK信任库没有正确更新或识别你的证书。以下是一些解决步骤,你可以尝试:
确认证书已正确导入: 确保jssecacerts
文件中确实包含了阿里云仓库的证书,并且该文件位于正确的路径下(通常是%JAVA_HOME%\jre\lib\security
或%JAVA_HOME%\lib\security
)。如果直接修改了cacerts
文件,请确保备份原始文件。
使用keytool命令检查和添加证书: 使用Java的keytool
工具手动检查和添加证书到信任库。首先,你需要导出阿里云仓库的证书到本地,然后用下面的命令将其导入到Java的信任库中:
keytool -importcert -file path_to_your_certificate.crt -alias aliyunmaven -keystore "%JAVA_HOME%\jre\lib\security\cacerts" -storepass changeit
这里path_to_your_certificate.crt
是阿里云仓库证书的路径,-alias
可以自定义,-storepass
是默认密码(除非你之前更改过)。
重启IDEA: 修改完信任库后,需要完全关闭并重新启动IntelliJ IDEA,以确保它使用的是更新后的证书信息。
检查网络代理设置: 如果你处于公司内网或者使用了代理服务器,可能需要在Maven的settings.xml
中配置代理设置,确保Maven能够通过代理访问外部资源。
直接使用http而非https: 作为临时解决方案,可以在Maven的settings.xml
中将阿里云仓库的URL由https
改为http
,但这不是最安全的做法,因为不加密的数据传输可能会有安全风险。
<repository>
<id>nexus-aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<name>Nexus aliyun</name>
</repository>
检查系统时间: 确保你的系统时间是准确的,错误的系统时间也可能导致SSL握手失败。
如果以上方法都不能解决问题,建议彻底卸载重装JDK,并在安装过程中确保所有安全相关的选项都保持默认,然后再重复上述步骤。希望这些建议能帮助你解决问题。