Hi,
I’ve created a simple application based on creator from site Spring Initializr with selected options:
- Project: Gradle - Kotlin
- Language: Java
- Spring Boot: 3.1.1
- Packaging: JAR
- Java: 17
When I run my app with command:
gradlew build
It’s OK - build is successfull. Now, I want to add some configuration for Spring Boot plugin:
tasks.named<BootRun>("bootRun") {
mainClass.set("com.example.demo.DemoApplication")
}
Build is not successfull:
Line 27: tasks.named<BootRun>("bootRun") {
^ Unresolved reference: BootRun
Line 27: tasks.named<BootRun>("bootRun") {
^ Type mismatch: inferred type is () -> ??? but Class<TypeVariable(S)!>! was expected
Line 28: mainClass.set("com.example.demo.DemoApplication")
^ Unresolved reference: mainClass
Here is my full build.gradle.kts
file:
plugins {
java
id("org.springframework.boot") version "3.1.1"
id("io.spring.dependency-management") version "1.1.0"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.named<BootRun>("bootRun") {
mainClass.set("com.example.demo.DemoApplication")
}
Regards