spring-boot - SpringBoot gradle 插件抱怨“未解决的参考:providedRuntime”
问题描述
我正在关注最新的SpringBoot gradle 插件参考,以便设置一个可以构建 uberjar 的 SpringBoot 项目。
以下是完整内容build.gradle.kts
:
plugins {
java
application
id("org.springframework.boot") version "2.2.1.RELEASE"
id("io.spring.dependency-management") version "1.0.8.RELEASE"
}
repositories {
jcenter()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testImplementation("org.testng:testng:6.14.3")
}
application {
// Define the main class for the application.
mainClassName = "com.demo.App"
}
val test by tasks.getting(Test::class) {
// Use TestNG for unit tests
useTestNG()
}
dependencyManagement {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}
不幸的是,当我运行 gradle 命令时,我收到以下错误:
> Configure project :
e: /Users/xux/Documents/toys/web/build.gradle.kts:15:5: Unresolved reference: providedRuntime
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/xux/Documents/toys/web/build.gradle.kts' line: 15
* What went wrong:
Script compilation error:
Line 15: providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
^ Unresolved reference: providedRuntime
1 error
我正在使用 Java 1.8.0_201、Gradle 6.0、Kotlin 1.3.50、Mac OS X 10.15.1 x86_64。
解决方案
推荐阅读
- c++ - 在 C++ 中将数组打印为表格
- excel - 在列中查找重复值返回带有消息框的行
- c - 宏迭代和返回值
- c# - 如何强制 Visual Studio 在编译时检查损坏的文件引用
- c++ - c++ - 如何为c ++中对象指针的常量向量赋值?
- flutter - Flutter,在警报对话框中打开卡片内显示的文本
- java - 如何根据Java中的鼠标位置向上旋转某些东西
- reactjs - 无法捕获状态变量值
- flutter - Flutter 应用程序无法在 apk-release 中运行,但可以在调试模式下运行(即使在授予 Internet 权限后)
- python - 在没有服务帐户的情况下使用谷歌云 sdk 进行身份验证