使用kotlin-spring插件,仍然得到类没有打开错误

Jay*_*Jay 5 spring gradle kotlin

尽管添加了kotlin-spring插件,但我得到的课程不能是最终的,需要开放.插件的整个目的是不要手动将open关键字添加到每个类.

请指导我使用Kotling-Spring插件处理下面的代码.

的build.gradle

buildscript {
    ext.kotlin_version = "1.1.2"

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version"
    }
}

apply plugin: "kotlin"
apply plugin: "kotlin-spring"
apply plugin: "kotlin-noarg"
apply plugin: "idea"

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
    compile"org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    compile "org.springframework:spring-context:4.3.8.RELEASE"
    testCompile "org.springframework:spring-test:4.3.8.RELEASE"
    testCompile "junit:junit:4.11"
}
Run Code Online (Sandbox Code Playgroud)

AppConfig.java

@Configuration
class AppConfig {

    @Bean
    fun game(): Game {
        return BaseballGame(redSox(),cubs())
    }

    @Bean
    fun redSox(): Team {
        return RedSox()
    }

    @Bean
    fun cubs(): Team {
        return Cubs()
    }
}
Run Code Online (Sandbox Code Playgroud)

错误:

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'AppConfig' may not be final. Remove the final modifier to continue.
Offending resource: AppConfig
Run Code Online (Sandbox Code Playgroud)

REF:https://kotlinlang.org/docs/reference/using-gradle.html#plugin-and-versions

zen*_*non 6

有同样的问题。在 Intellij 中启用注释处理解决了这个问题:

在此处输入图片说明