【问题标题】:Dependencies are failed to resolve when migrated from Spring Boot 1.5.10 to 2.0.0从 Spring Boot 1.5.10 迁移到 2.0.0 时无法解析依赖项
【发布时间】:2018-08-11 13:33:45
【问题描述】:

所以,我将我的基本应用程序从 Spring Boot 1.5.10 迁移到了 2.0.0。我正在使用 Gradle,在迁移之前,我总是排除编译依赖项的工件的版本号。迁移后,gradle build task 开始抛出如下错误:

BUILD FAILED in 0s
2 actionable tasks: 1 executed, 1 up-to-date

During the build, one or more dependencies that were declared without a version failed to resolve:
    org.springframework.boot:spring-boot-starter-data-rest:
    org.springframework.boot:spring-boot-starter-web:
    org.springframework.boot:spring-boot-starter-data-jpa:

Did you forget to apply the io.spring.dependency-management plugin to the llutrackr project?

我的build.gradle(我排除了不相关的部分):

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.RELEASE")
    }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-data-rest")
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-web')
}

我给对应的依赖加上版本号后,问题就解决了。为什么使用 gradle 构建 Spring Boot 2.0 项目需要进行此更改?即使是弹簧指南也不包括工件版本号。 An example

【问题讨论】:

    标签: spring-boot gradle


    【解决方案1】:

    尝试将以下内容添加到您的 build.gradle 文件中

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

    https://docs.spring.io/spring-boot/docs/2.0.0.BUILD-SNAPSHOT/gradle-plugin/reference/html/

    【讨论】:

    • apply plugin: 'io.spring.dependency-management' 缺少此行。现在它起作用了。谢谢...
    猜你喜欢
    • 2018-01-10
    • 2018-05-13
    • 2019-01-27
    • 2019-09-11
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    • 2020-10-02
    • 1970-01-01
    相关资源
    最近更新 更多