我是使用gradle build的spring boot。直到昨天,gradle构建才得以顺利进行。但是今天我得到了以下错误;
Could not resolve all artifacts for configuration ':classpath'. Could not find spring-core.jar (org.springframework:spring-core:5.2.0.BUILD-SNAPSHOT:20190328.215418-203). Searched in the following locations: https://repo.spring.io/snapshot/org/springframework/spring-core/5.2.0.BUILD-SNAPSHOT/spring-core-5.2.0.BUILD-20190327.205120-195.jar Could not find spring-jcl.jar (org.springframework:spring-jcl:5.2.0.BUILD-SNAPSHOT:20190328.215418-203). Searched in the following locations: https://repo.spring.io/snapshot/org/springframework/spring-jcl/5.2.0.BUILD-SNAPSHOT/spring-jcl-5.2.0.BUILD-20190327.205120-195.jar
这是我的
build.gradle
文件buildscript {
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/snapshot' }
maven { url 'https://repo.spring.io/milestone' }
maven {url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.3.RELEASE")
}
}
plugins {
id 'org.springframework.boot' version '2.2.0.BUILD-SNAPSHOT'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'idea'
group = 'me.namila'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/snapshot' }
maven { url 'https://repo.spring.io/milestone' }
jcenter()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
当访问相关的URL时,我能看到的是gradle正在搜索3月27日的构建(
spring-jcl-5.2.0.BUILD-20190327.205120-195.jar
),而服务器具有28th的构建spring-jcl-5.2.0.BUILD-20190328.164750-201.jar
。如何解决这个错误?我也添加了buildscript存储库。有什么建议吗?
最佳答案
正如Antoniossss在评论中所说,发生这种情况是因为快照构建失败。为了解决这个问题,我移至springboot的先前构建版本。我对build.gradle
文件做了以下更改;
id 'org.springframework.boot' version '2.1.3.RELEASE'
将
'2.2.0.BUILD-SNAPSHOT'
更改为2.1.3版本。这解决了错误。 :)
关于java - Gradle无法找到Spring核心jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55413530/