2017-06-02 29 views
3

尽管添加了kotlin-spring插件,但我不能最终获得类,需要打开。插件的全部目的是不为每个类手动添加open关键字。使用kotlin-spring插件,仍然没有打开类的错误

请指导我让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" 
} 

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() 
    } 
} 

错误:

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 

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

回答

0

有同样的问题。在启用的IntelliJ注释处理解决该问题:

enter image description here

+1

仍然无法正常工作.. – szxnyc

相关问题