0

I have a Gradle java project. When I tried to import/ open, I am getting dependency can't be resolved error.

Initially I tried with IntelliJ, so doubt IntelliJ issue ann tried Netbeans, but no luck. After I tried just gradle build command on CLI, same issue.

* What went wrong:
A problem occurred configuring root project 'cloud-smart-city'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.1.9.RELEASE.
 Required by:
     project :
  > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.1.9.RELEASE.
     > Could not get resource 'https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/2.1.9.RELEASE/spring-boot-gradle-plugin-2.1.9.RELEASE.pom'.
        > Could not GET 'https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/2.1.9.RELEASE/spring-boot-gradle-plugin-2.1.9.RELEASE.pom'.
           > java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
  > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.1.9.RELEASE.
     > Could not get resource 'https://jcenter.bintray.com/org/springframework/boot/spring-boot-gradle-plugin/2.1.9.RELEASE/spring-boot-gradle-plugin-2.1.9.RELEASE.pom'.
        > Could not GET 'https://jcenter.bintray.com/org/springframework/boot/spring-boot-gradle-plugin/2.1.9.RELEASE/spring-boot-gradle-plugin-2.1.9.RELEASE.pom'.
           > java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

Below given is the build.gradle

buildscript {
    ext {
        springBootVersion = '2.1.9.RELEASE'
        springCloudVersion = 'Greenwich.SR3'
        alibabaSCVersion = '2.2.0.RELEASE'
    }
    repositories {
        mavenLocal()
        maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
        maven { url "http://repo.spring.io/snapshot" }
        maven { url "http://repo.spring.io/milestone" }
        jcenter()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

allprojects {
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        jcenter()
        mavenCentral()
    }
    tasks.withType(JavaCompile) {
        options.encoding = "UTF-8"
    }
}

subprojects {
    apply plugin: 'java'
    apply plugin: 'idea'
    apply plugin: 'io.spring.dependency-management'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    dependencies {
        annotationProcessor('org.projectlombok:lombok:1.18.8')
        implementation("org.projectlombok:lombok:1.18.8")
        implementation("com.google.guava:guava:20.0")
        implementation('com.alibaba:fastjson:1.2.60')
    }

    dependencyManagement {
        imports {
            mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:${alibabaSCVersion}"
            mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
        }
    }
}

I have tried with Gradle version 5.2.1, 6.0 and 6.3

The project have multiple submodules.

This is building every other machine. So I think it is something with my Gradle.

I am using Windows 10 as build system.

Thanks in advance

smac89
  • 39,374
  • 15
  • 132
  • 179
noobEinstien
  • 3,147
  • 4
  • 24
  • 42
  • It is more likely to be an issue with your JDK distribution. Maybe see if some of the answers [here](https://stackoverflow.com/questions/6784463/error-trustanchors-parameter-must-be-non-empty) can be of help. – Bjørn Vester Apr 28 '20 at 09:48
  • Might be related to [this](https://jfrog.com/knowledge-base/why-do-we-see-the-following-error-java-lang-runtimeexception-unexpected-error-java-security-invalidalgorithmparameterexception-the-trustanchors-parameter-must-be-non-empty/). Also why have you choosen to take such an elaborate route to applying the springboot plugin? Why don't you use the plugins DSL as shown [here](https://plugins.gradle.org/plugin/org.springframework.boot)? – smac89 Apr 28 '20 at 14:39

1 Answers1

0

Check maven url is correct in build.gradle file. Can use multiple repositories for resolving dependencies.

repositories {
    mavenCentral()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
}