0

I modified the build.gradle file of the newly created gradle project named build.gradle.kts, and then copied the build.gradle.kts content of the demo project generated by spring initializr, and then build, this file reported a lot of errors, but spring initializr project can be built correctly.

The two build.gradle.kts are exactly the same. What's wrong?

This is the wrong screenshot https://s2.ax1x.com/2019/08/21/mNvASA.png

This is the correct screenshot https://s2.ax1x.com/2019/08/21/mNvEQI.png

This is the content

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"
    }
}
Stephane Nicoll
  • 31,977
  • 9
  • 97
  • 89
gelong
  • 1
  • 2
  • Have you tried turning it off an on again? That is, have you tried `Gradle → Reimport All Gradle Projects`, or perhaps `File → Invalidate Caches / Restart...`? – ordonezalex Aug 26 '19 at 06:05
  • I have restarted it many times and tried what you said, but it didn't solve the problem. – gelong Aug 29 '19 at 00:56
  • Check the Gradle wrapper version in both projects: `./gradlew -v` (or `gradlew.bat -v` on Windows). And also make sure that you IDE uses gradle wrapper instead of installation of Gradle. – Max Farsikov Aug 29 '19 at 05:39

0 Answers0