You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gradle Kotlin DSL配置依赖时应使用哪个compile函数?

Gradle Kotlin DSL 依赖声明问题解决

核心结论:优先用 implementation 替代废弃的 compile

Gradle 5.x 及以上版本已将 compile 标记为废弃,官方推荐使用 implementation 作为依赖配置。在 Kotlin DSL 中,无需额外导入任何函数,直接编写:

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-webflux")
}

若必须使用 compile(不推荐)

如果因特殊需求要保留 compile,需导入 Kotlin DSL 提供的专属扩展函数:

import org.gradle.kotlin.dsl.compile

你之前导入的 JSON 指针相关 compile 函数属于无关的 Gradle 内部 API,完全不对应依赖配置场景,这正是构建失败的原因。

内容的提问来源于stack exchange,提问作者Chris Schmitz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 09:42:36