I have the following configuration for a Springboot application:
DemoApplication.kt
package com.planes.planesserver
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("war")
id("org.springframework.boot") version "3.2.0"
id("io.spring.dependency-management") version "1.1.4"
kotlin("jvm") version "1.9.21"
kotlin("plugin.spring") version "1.9.20"
kotlin("plugin.jpa") version "1.9.20"
id("org.flywaydb.flyway") version "7.15.0"
}
group = "com.planes.planesserver"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
//here list of dependencies
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<Jar> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes["Main-Class"] = "com.planes.planesserver.DemoApplication"
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
springBoot {
mainClass.set( "com.planes.planesserver.DemoApplication")
}
//other stuff
I am deploying with the bootJar gradle task. When trying to run the jar with java -jar I get the error: main class cannot be found or loaded.
I unpacked the jar archive. Under BOOT-INF/classes/com/planes/planesserver there exists the file DemoApplication.class as well as the DemoApplicationKt.class
Can anyone give me a hint in the right direction ?