0

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 i.e JPA, WEB DEV tools etc
  3. then selecting and filling up the required stuffs i.e. 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"

Rajan Chauhan
  • 461
  • 2
  • 7
  • 18
  • got a work around on intellij idea setting open Build, Execution, Deployment --> Maven --> Runner here set VM Options: "-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true" But i have to do this for creating every project, need a permanent way so that i don't have to do this everytime. – Rajan Chauhan Mar 27 '20 at 15:43
  • How does your settings.xml in .m2 folder looks like? – Alexander Plickat Mar 27 '20 at 17:03
  • @AlexanderPlickat there isn't any file named settings.xml in .m2 folder – Rajan Chauhan Mar 28 '20 at 07:08
  • I traced it from intellij's setting --> build execution deployment -->build tool --> maven --> user settings file. when i click on override it takes me to the .m2 folder and there is't any file named .settings.xml however when i changed maven home directory from bundled to my local system installed maven directory dependencies gets resolved. – Rajan Chauhan Mar 28 '20 at 07:17
  • 1
    The remote server's certificate must be [imported into the JDK key store](https://docs.oracle.com/javase/tutorial/security/toolsign/rstep2.html) that is used for Maven importing in IDE in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Importing | **JDK for importer** box. – Andrey Mar 29 '20 at 08:43
  • @Andrey it's a very high level information for me, could you please elaborate it. Right now when i move to the path specified by you i see JDK for Importer auto filled with intellij's Use Internal JRE("java version 11.0.4.....). What should i do from here ? i have never played with this key store thing before. – Rajan Chauhan Mar 31 '20 at 05:37

2 Answers2

0

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.

Rajan Chauhan
  • 461
  • 2
  • 7
  • 18
0

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.

Waqas Ahmed
  • 4,801
  • 3
  • 36
  • 45
Amar
  • 1