【问题标题】:spring boot plugin and gradle dependency implementationspring boot插件和gradle依赖实现
【发布时间】:2020-09-27 06:35:51
【问题描述】:

我们一直在使用 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 创建的fat jar 确实不包含BOOT-INF/lib 下所需的库了?如果我将“实现”替换为“编译”,它会再次按预期工作。

是否需要配置一些东西才能让 spring-boot-plugin 添加它们?还是需要提前将项目升级到spring boot 2?

【问题讨论】:

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


    【解决方案1】:

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

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

    假设你有模块 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' 的库)。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-23
      • 2021-10-08
      • 2016-02-15
      • 2016-09-17
      • 2019-01-30
      • 2019-07-16
      • 2018-01-31
      相关资源
      最近更新 更多