首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在springboot中使用gradle时,加载依赖项遇到sun.security.validator.validatorexception。我不知道怎么解决它

在springboot中使用gradle时,加载依赖项遇到sun.security.validator.validatorexception。我不知道怎么解决它
EN

Stack Overflow用户
提问于 2020-05-03 12:41:42
回答 1查看 113关注 0票数 0

我使用gradle来构建springboot项目,但是gradle加载依赖总是不好用。错误如下:

代码语言:javascript
复制
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'server'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE.
     Required by:
         project :
      > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE.
         > Could not get resource 'http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-gradle-plugin/2.2.2.RELEASE/spring-boot-gradle-plugin-2.2.2.RELEASE.pom'.
            > Could not GET 'https://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-gradle-plugin/2.2.2.RELEASE/spring-boot-gradle-plugin-2.2.2.RELEASE.pom'.
               > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

我尝试在Java证书库中添加相应的证书,但没有用。我现在可以直接在浏览器上下载它,但我不能使用gradle添加依赖项。我希望我能得到帮助,谢谢。

我的配置如下:

代码语言:javascript
复制
buildscript {
    ext {
        springBootVersion = '2.2.2.RELEASE'
    }
    repositories {
        maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.cqut.spider'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web' 
    implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.0'
    testImplementation 'org.springframework.boot:spring-boot-starter-test' 
    implementation 'com.squareup.okhttp3:okhttp:3.12.1'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation  group: 'mysql', name: 'mysql-connector-java', version: '8.0.15'
    implementation 'com.github.pagehelper:pagehelper-spring-boot-starter:1.2.5'

    runtimeOnly('mysql:mysql-connector-java')
    compile 'tk.mybatis:mapper-spring-boot-starter:1.1.5'
    compile "net.sf.json-lib:json-lib:2.4:jdk15"

}
EN

回答 1

Stack Overflow用户

发布于 2020-05-03 15:08:09

如果你用http访问maven.aliyun.com,你会被重定向到https,这很好,也是目前绝大多数存储库都在做的事情。您的构建文件仍然有一个http存储库,您需要将其更改为https,我猜错误将消失。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61569717

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档