【问题标题】:Gradle couldn't locate the Spring core jarGradle 找不到 Spring 核心 jar
【发布时间】:2019-08-20 03:56:51
【问题描述】:

我是使用 gradle build 的 spring boot。直到昨天 gradle build 运行顺利。但是今天我收到了以下错误;

无法解析配置“:classpath”的所有工件。 找不到 spring-core.jar (org.springframework:spring-core:5.2.0.BUILD-SNAPSHOT:20190328.215418-203)。 在以下位置搜索: https://repo.spring.io/snapshot/org/springframework/spring-core/5.2.0.BUILD-SNAPSHOT/spring-core-5.2.0.BUILD-20190327.205120-195.jar 找不到 spring-jcl.jar (org.springframework:spring-jcl:5.2.0.BUILD-SNAPSHOT:20190328.215418-203)。 在以下位置搜索: 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'
}

访问相关网址时,我可以看到 gradle 正在搜索 27th March build (spring-jcl-5.2.0.BUILD-20190327.205120-195.jar) 而服务器具有 28th build spring-jcl-5.2.0.BUILD-20190328.164750-201.jar。如何解决此错误?我也添加了 buildscript 存储库。有什么建议吗?

【问题讨论】:

  • 可能快照构建已损坏 :)
  • @Antoniossssso 如何修复它:/ 我需要运行该项目
  • 使用早期版本。

标签: java spring spring-boot gradle


【解决方案1】:

buildscript 存储库和依赖项一团糟,不匹配:

buildscript {
    repositories {
        maven { url 'https://repo.spring.io/libs-milestone' }
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.2.0.BUILD-SNAPSHOT'
    }
}

apply plugin: 'org.springframework.boot'

请参阅documentation

【讨论】:

    【解决方案2】:

    正如 Antoniosss 在 cmets 中所说,这是因为快照构建失败而发生的。为了修复它,我移到了以前的 springboot 构建版本。我对build.gradle 文件进行了以下更改;

    id 'org.springframework.boot' version '2.1.3.RELEASE'
    

    '2.2.0.BUILD-SNAPSHOT' 更改为 2.1.3 版本。这修复了错误。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      相关资源
      最近更新 更多