[英]Intellij not able to resolve dependency for spring boot project
I am creating a simple spring boot project using intellij ideas's built in spring initializer feature.我正在使用 intellij idea 的内置弹簧初始化程序功能创建一个简单的弹簧启动项目。 below are the steps that i am performing.以下是我正在执行的步骤。
Now on clicking after finish button IDE open's the project, and on bottom i see resolving dependency for a very short period (after clicking the maven tool window there are no dependencies which i selected earlier)现在单击完成按钮后IDE打开项目,在底部我看到在很短的时间内解决依赖关系(单击maven工具窗口后没有我之前选择的依赖项)
I tried to resolved the dependency using command mvn:install but get's an error我尝试使用命令 mvn:install 解决依赖关系,但出现错误
"Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.6.RELEASE from/to central ( https://repo.maven.apache.org/maven2 ): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target" “无法将工件 org.springframework.boot:spring-boot-starter-parent:pom:2.2.6.RELEASE 从/到中央( https://repo.maven.apache.org/maven2):sun.security 。 validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径”
I tried maven command clean install using cmd from my project directory and got the same error mentioned above in the question.我使用项目目录中的 cmd 尝试了maven命令clean install ,并在问题中遇到了上述相同的错误。 The issue has no relation to IntelliJ IDEA.该问题与 IntelliJ IDEA 无关。 JVM used to run Maven seems to miss the certificates needed to access the repository.用于运行 Maven 的 JVM 似乎缺少访问存储库所需的证书。
So below are the steps i followed and it fixed this issue for me.所以下面是我遵循的步骤,它为我解决了这个问题。
Get the certificate from https://repo.maven.apache.org/maven2/ .从https://repo.maven.apache.org/maven2/获取证书。
(to get the certificate follow steps) - (要获得证书,请按照步骤) -
open https://repo.maven.apache.org/maven2/ .打开https://repo.maven.apache.org/maven2/ 。
On certificate window click details tab then click copy to file button then next button.在证书窗口上单击详细信息选项卡,然后单击复制到文件按钮,然后单击下一步按钮。
accept the default file format and save it to locally on your system.接受默认文件格式并将其保存到系统本地。
Now here is the command to install certificate.现在这里是安装证书的命令。 In command prompt, go to directory C:\Program Files\Java\jdk1.8.0_144\jre\lib\security and do the following.在命令提示符下,转到目录 C:\Program Files\Java\jdk1.8.0_144\jre\lib\security 并执行以下操作。
keytool -import -file C:\maven.cer -keystore cacerts -alias mavencert keytool -import -file C:\maven.cer -keystore cacerts -alias mavencert
Note : run cmd as an administrator.注意:以管理员身份运行 cmd。
Please use the following steps to resolve the dependency issue in Intellij IDE:请使用以下步骤解决 Intellij IDE 中的依赖问题:
IntelliJ -> Maven -> Toggle Offline mode option
Deleting .idea
folder, .m2
folder and invalidating cache won't worked for but toggling offline mode done the job.删除.idea
文件夹、 .m2
文件夹和使缓存无效,但切换离线模式完成了这项工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.