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)
}
}
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-12-12 11:00:00 +0000
Seen: 21 times
Last updated: Jul 24 '21
What are the typical approaches found in a Gradle build script?
What is the method to show the dependencies in Java?
What does the "Invalid source release 1.7" error mean when using gradle for compilation?
How can we avoid the duplication of Kotlin class jetified-kotlin-stdlib-1.8.10 in Android (Java)?
What is the reason for the failure of Task :app:signReleaseBundle in React Native Android?
How can build variables be accessed in code in Kotlin multiplatform?
Why can't IntelliJ IDEA detect the Kotlin multiplatform library?