首页 > 解决方案 > Spring Boot Kotlin 项目在 Eclipse 中不起作用

问题描述

我有一个在 Eclipse 中运行的 Spring Boot 项目,具有以下版本

Spring Boot: 2.1.6.RELEASE
Kotlin:1.3.41

代码在 IntellIJ 中运行良好 - 但在 eclipse 中我得到这些错误

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'SwaggerConfig' may not be final. Remove the final modifier to continue.
Offending resource: class path resource [com/kotlin/springboot/kotlindemo/config/SwaggerConfig.class]

这是 SwaggerConfig 类

@Configuration
@EnableSwagger2
class SwaggerConfig {

    @Bean
    fun api(): Docket = Docket(DocumentationType.SWAGGER_2)
    .select()
    .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
    .build()

}

我的 pom.xml 文件中有以下插件设置

<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>

同样,在 IntelliJ 中一切正常,但在 eclipse 中不能正常工作有什么想法可以在 eclipse 中解决这个问题吗?

谢谢达米安

标签: springeclipsespring-bootintellij-ideakotlin

解决方案


我升级到最新版本的 kotlin 插件,这解决了我面临的问题。


推荐阅读