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
相关产品推荐
相关产品推荐

