我修改了新创建的gradle项目build.gradle.kts的build.gradle文件,然后复制了spring initializr生成的演示项目的build.gradle.kts内容,然后进行构建,该文件报告了错误很多,但是可以正确构建spring initializr项目。
两个build.gradle.kts完全相同。怎么了?
这是错误的屏幕截图https://s2.ax1x.com/2019/08/21/mNvASA.png
这是正确的屏幕截图https://s2.ax1x.com/2019/08/21/mNvEQI.png
这是内容
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.1.7.RELEASE"
id("io.spring.dependency-management") version "1.0.8.RELEASE"
kotlin("jvm") version "1.2.71"
kotlin("plugin.spring") version "1.2.71"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
dependencies {
api("org.springframework.boot:spring-boot-starter")
api("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}