简体   繁体   中英

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. 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
  3. then selecting and filling up the required stuffs ie 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)

I tried to resolved the dependency using command mvn:install but get's an error

"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"

I tried maven command clean install using cmd from my project directory and got the same error mentioned above in the question. The issue has no relation to IntelliJ IDEA. JVM used to run Maven seems to miss the certificates needed to access the repository.

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/ .

    (to get the certificate follow steps) -

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

  3. press CNTRL+SHIFT+J to open deveoloper window.
  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.
  9. You have to install certificate in jdk path. In my case the path is 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.

    keytool -import -file C:\maven.cer -keystore cacerts -alias mavencert

    Note : run cmd as an administrator.

Please use the following steps to resolve the dependency issue in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM