添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Is io.spring.dependency-management plugin required when using Spring Boot 2.3+ and Spring Cloud?

Ask Question

I'm using Gradle 6.6 to build my Spring Boot app. According to this post , the io.spring.dependency-management plugin is no longer needed since Gradle 5+ supports BOM files.

However, I receive the following error if I remove the plugin:

Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.6.1-bin.zip'.
Build file 'C:\my-app\build.gradle' line: 14
A problem occurred evaluating root project 'my-app'.
Could not find method dependencyManagement() for arguments [build_6e8ejdhnd2no2m9jw221sctmn3$_run_closure2@432e46e2] on root project 'my-app' of type org.gradle.api.Project.

Line 14 of my build.gradle file is referenced in the above error. Here are lines 14-18:

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR8"

Is there another way to specify the required dependencies for Spring Cloud without using io.spring.dependency-management plugin?

dependencyManagement() is provided exclusively by the io.spring.dependency-management plugin. Which means you cannot use it if you don't use the plugin. And in that case you have to use the gradle's platform capability. In the post you linked there's an example of that.

To fix your build, remove the dependencyManagement part and add

implementation platform("org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR8")

to your dependencies { }

Reference: https://docs.spring.io/dependency-management-plugin/docs/current/reference/html/#dependency-management-configuration-dsl

The Spring Dependency Management plugin also aims to provide the same set of dependencies and versions as what Maven Dependency Management would produce. Gradle processing of a BOM follows slightly different rules. – Corneil du Plessis Jun 2, 2022 at 12:17

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.