【发布时间】:2019-06-29 18:56:05
【问题描述】:
由于以下原因,我无法启动我的 spring boot kotlin 应用程序:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'TestApplication' may not be final. Remove the final modifier to continue.
我知道 @configuration 和 @bean 类不能是最终的,所以我在我的 pom 文件中添加了 allopen 插件:
<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>
如果我打包我的应用程序并运行它(java -jar)它可以工作,但是当我尝试从 STS 启动它时它不会工作。
Kotlin 版本:1.2.71 Kotlin eclipse 插件:0.8.13 STS:3.9.5
【问题讨论】: