我正在关注最新的SpringBoot gradle plugin reference,以便设置可以构建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。