1 | initial version |
This error occurs when bytecode generated with a higher version of the JVM is being used in a lower version of the JVM. To resolve this error in the context of Spring Boot 3 and Kotlin, you can try the following steps:
If you are using IntelliJ IDEA, you can update the Kotlin plugin to the latest version and set the JVM target to 17 in the Project Structure settings. If you are using Gradle, you can update the Kotlin plugin version in the build.gradle file and set the targetCompatibility to 1.8.
Example for Gradle:
plugins {
id 'org.springframework.boot' version '2.5.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.jetbrains.kotlin.jvm' version '1.5.10' // Update Kotlin plugin version
}
springBoot {
mainClass = 'com.example.Application'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = '17' // Set JVM target 17
freeCompilerArgs += ['-Xjvm-default=compatibility'] // This flag help disable new features and make the bytecode compatible with Java 8 (if that is your Java version)
}
}