简体   繁体   English

Intellij 无法解决 Spring Boot 项目的依赖关系

[英]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.以下是我正在执行的步骤。

  1. File --> new --> project --> spring initializer文件 --> 新建 --> 项目 --> 弹簧初始化程序
  2. Select the required dependency or starters ie JPA, WEB DEV tools etc选择所需的依赖项或启动程序,即 JPA、WEB DEV 工具等
  3. then selecting and filling up the required stuffs ie gropId, ArtifactId.然后选择并填写所需的东西,即 gropId、ArtifactId。

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.所以下面是我遵循的步骤,它为我解决了这个问题。

  1. Get the certificate from https://repo.maven.apache.org/maven2/ .https://repo.maven.apache.org/maven2/获取证书。

    (to get the certificate follow steps) - (要获得证书,请按照步骤) -

  2. open https://repo.maven.apache.org/maven2/ .打开https://repo.maven.apache.org/maven2/

  3. press CNTRL+SHIFT+J to open deveoloper window.CNTRL+SHIFT+J打开开发者窗口。
  4. go to security tabs.转到安全选项卡。
  5. click View certificate (this will open the certificate window).单击查看证书(这将打开证书窗口)。
  6. On certificate window click details tab then click copy to file button then next button.在证书窗口上单击详细信息选项卡,然后单击复制到文件按钮,然后单击下一步按钮。

  7. accept the default file format and save it to locally on your system.接受默认文件格式并将其保存到系统本地。

  8. save the certificate on local drive, i saved it in C:\maven.cer.将证书保存在本地驱动器上,我将其保存在 C:\maven.cer 中。
  9. You have to install certificate in jdk path.您必须在 jdk 路径中安装证书。 In my case the path is C:\Program Files\Java\jdk1.8.0_144\jre\lib\security .在我的情况下,路径是C:\Program Files\Java\jdk1.8.0_144\jre\lib\security
  10. 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.

相关问题 在初始化 Spring Boot 项目 IntelliJ 想法时,它要求选择依赖项 - while initialize the spring boot project IntelliJ idea it is asking to select the dependency 为什么 IntelliJ 在我的 Spring 引导项目中添加错误的 maven 依赖项? - Why is IntelliJ adding wrong maven dependency in my Spring Boot project? 无法将 JPA 依赖项添加到 spring-boot 项目中 - Not able to add JPA dependency into spring-boot project 在Spring中手动解决依赖关系[启动] - Manually resolve a dependency in Spring [Boot] IntelliJ 如何能够从命令行解决依赖关系并运行 spring 引导(maven)应用程序,这是不可能的? - how IntelliJ is able to resolve dependencies and run a spring boot (maven) application while from the command line, it is not possible? 在Spring Boot项目中找不到依赖项 - Dependency not found in Spring Boot project 如何检查 Spring 引导项目(Intellij Idea)中的哪个位置使用了特定的 maven 依赖项? - How to check that where in the Spring boot project (Intellij Idea), particular maven dependency is used? Gradle、Kotlin:如何在 intellij 中添加另一个 Spring Boot 项目作为模块依赖项 - Gradle, Kotlin : How to add another spring boot project as a module dependency in intellij Gradle无法解决Spring Boot HATEOAS依赖性 - Gradle cannot resolve Spring Boot HATEOAS dependency Spring Boot Test无法解决存储库依赖关系 - Spring Boot Test cannot resolve repository dependency
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM