从Spring Boot 1.5.10迁移到2.0.0时,依赖关系无法解决

问题描述 投票:8回答:1

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

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个回答
18
投票

尝试在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/

© www.soinside.com 2019 - 2024. All rights reserved.