春季启动插件和gradle依赖项实现

时间:2020-06-08 10:05:34

标签: spring-boot gradle spring-boot-gradle-plugin

我们一直在使用gradle spring boot插件版本1.5.14和gradle 4.10.3进行构建。将gradle升级到6.2.2后,我们还将依赖项定义从compile group更改为implementation group,即:

compile group: 'org.springframework.boot', name: 'spring-boot-starter-integration'

implementation group: 'org.springframework.boot', name: 'spring-boot-starter-integration'

通过gradle assemble创建的胖罐确实不包含BOOT-INF/lib下的必需库了吗?如果我将“实现”替换为“编译”,它将再次按预期工作。

是否需要配置某些东西,以便spring-boot-plugin添加它们?还是我需要事先将项目升级到Spring Boot 2?

1 个答案:

答案 0 :(得分:0)

实现只会为它声明的那个模块引入依赖。

编译将允许依赖模块的模块也使用依赖项。

假设模块 A 依赖于模块 B。 模块 A 和 B 都需要依赖:

com.font:font1:1.1.1

如果 B 使用:

implementation 'com.font:font1:1.1.1'

A 将看不到 font1,并且还需要将其引入自己的 build.gradle 文件中。

compile 'com.font:font1:1.1.1' 

将使其可用于整个类路径(无论如何都应该避免,新的等效项适用于使用“api”而不是“compile”的库)。

在没有看到您的项目目录的情况下,我假设某些依赖项没有被拉到以前从层次结构中较低的依赖项中获取的位置。除非您有一个庞大的多模块项目,否则您应该能够通过一次将编译更改为一个实现来轻松找到缺失的依赖项。