【发布时间】:2021-12-23 10:40:50
【问题描述】:
将 gradle 包装器更新到 7.3.2 版后,在尝试构建我的 spring boot 项目时出现以下错误:
error: package org.springframework.context.annotation does not exist
import org.springframework.context.annotation.Bean;
为什么会这样?
更新: 找到了问题,但还不知道如何解决。 我的项目中有多个模块。我有一个由其他模块使用的“通用”模块。旧的 gradle 版本将公共项目的库添加到其他模块的 compileClasspath 中,而新版本仅将它们添加到 runtimeClasspath 中。
依赖项过去被声明为编译,现在使用 gradle 7+ 我不得不将它们更改为实现。
有什么建议吗?
在其他模块中:
dependencies {
implementation project(':common')
...
}
在通用模块中:
dependencies {
implementation spring.web
...
}
【问题讨论】:
-
您可以发布您的
build.gradle文件吗? -
@ata 我更新了问题
标签: java spring spring-boot gradle build.gradle