Search code examples
springeclipsespring-bootintellij-ideakotlin

Spring Boot Kotlin Project Not Working In Eclipse


I have a spring boot project running in eclipse with the following versions

Spring Boot: 2.1.6.RELEASE
Kotlin:1.3.41

The code runs fine in IntellIJ - but in eclipse I get these errors

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]

Here is the SwaggerConfig class

@Configuration
@EnableSwagger2
class SwaggerConfig {

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

}

I have the following plugins setup in my pom.xml file

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

Again, all works fine in IntelliJ but not eclipse Any ideas what can be done to resolve this issue in eclipse?

Thanks Damien


Solution

  • I upgraded to the latest version of the kotlin plugin and this resolved the issues I was facing.