Spring Tool Suite: @Configuration class may not be final. Remove the final modifier to continue

I am unable to launch my spring boot kotlin app, due to the following:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'TestApplication' may not be final. Remove the final modifier to continue.

I know that @configuration and @bean classes cannot be final so I add the allopen plugin in my pom file:

<build> <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <configuration> <args> <arg>-Xjsr305=strict</arg> </args> <compilerPlugins> <plugin>spring</plugin> </compilerPlugins> </configuration> <dependencies> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-allopen</artifactId> <version>${kotlin.version}</version> </dependency> </dependencies> </plugin> </plugins>
</build>

If I package my application and run it (java -jar) it works, but when I try to launch it from STS it won't work.

Kotlin version: 1.2.71 Kotlin eclipse plugin: 0.8.13 STS: 3.9.5

0

2 Answers

This Question Can be Duplicate of :

IntelliJ Idea 2017.3 unable to start Kotlin Spring Boot App - @Configuration class may not be final

or

Used kotlin-spring plugin, still getting class not open error

. Anyways , I Just found Solution

You Just need to add open modifier to TestApplication kotlin class

@SpringBootApplication
open class TestApplication 

might Solve your Issue .

4

I had the same problem. You must configure the Kotlin plugin under Preferences > Kotlin > Compiler and enable Compiler plugins spring.

Kotlin Compiler Configuration Dialog

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like