spring - springboot中使用gradle时,加载依赖遇到sun.security.validator.validatorexception。我不知道如何解决
问题描述
我正在使用gradle构建springboot项目,但是gradle加载依赖总是不好。错误如下:
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添加依赖。希望能得到帮助,谢谢。
我的配置如下:
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"
}
解决方案
如果您使用 访问 maven.aliyun.com http
,您将被重定向到https
,这很好,现在绝大多数存储库都在这样做。您的构建文件仍然有一个http
存储库,您需要将其更改为https
,我猜错误会消失。
推荐阅读
- r - 如何从我的 NMDS 图中检索原始输出数据?
- firefox - 导航器 MediaDevices getUserMedia notAllowedError
- reactjs - 如何在 ReactJS 中设置或清除 material-ui Input 的值
- angular - MatSort 显示箭头,但实际上并未对数据进行排序
- php - 如何使用数据库中的国家/地区填充 Jvector 地图?
- r - R聚合 - 命名结果列
- python-2.7 - 使用 SUBPROCESS.POPEN.COMMUNICATE() 方法时,从 Cloud Firstore 获取数据会导致 OSError
- python - 使用 dask 阅读时如何跳过坏行?
- backbone.js - 导航到 Backbone.js 中的不同视图后,如何取消绑定子视图?
- php - 在每个循环结束时删除循环内创建的 XML 元素