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

lev*_*ver 10 gradle spring-boot

因此,我将我的基本应用程序从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?
Run Code Online (Sandbox Code Playgroud)

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')
}
Run Code Online (Sandbox Code Playgroud)

在我将版本号添加到相应的依赖项后,问题就解决了.为什么使用gradle构建Spring Boot 2.0项目需要进行此更改?甚至弹簧指南也不包括工件版本号.一个例子

mis*_*der 22

尝试在build.gradle文件中添加以下内容

apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
Run Code Online (Sandbox Code Playgroud)

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

  • `apply plugin: 'io.spring.dependency-management'` 缺少这一行。现在它起作用了。谢谢... (2认同)