IntelliJ Idea 2017.3无法启动Kotlin Spring Boot App - @Configuration类可能不是最终版 [英] IntelliJ Idea 2017.3 unable to start Kotlin Spring Boot App - @Configuration class may not be final
问题描述
我能够从IntelliJ 2017.3推出Spring Boot Kotlin应用程序。在最后一次IntelliJ修复更新后,我无法从IDE启动该应用程序,获得此异常:
I was able to launch a Spring Boot Kotlin App from IntelliJ 2017.3. After the last IntelliJ fix update I cannot start that application from the IDE, getting this exception:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'AccessConfig' may not be final
我可以开始它像往常一样从终端: java -jar xxxx.jar
I can start it from a terminal as usual: java -jar xxxx.jar
这是没有任何意义的,因为我我在我的Gradle配置中使用必要的Kotlin Spring插件:
This doesn't make any sense since I am using the necessary Kotlin Spring plugin in my Gradle config:
buildscript {
ext {
kotlinVersion = '1.2.21'
springBootVersion = '2.0.0.RC1'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven'
...
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
repositories {
mavenLocal()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "http://repo.maven.apache.org/maven2" }
maven { url 'https://jitpack.io' }
}
ext {
springCloudVersion = 'Finchley.M5'
mmaReleaseTrainVersion = 'Callao-SNAPSHOT'
junitVersion = '5.0.2'
}
任何想法?
更新:
一种更简单的重现方法,只需使用IntelliJ的Spring初始化程序创建一个Spring Boot项目,你就会看到相同的结果:
A simpler way to reproduce, just create a Spring Boot project with the Spring initializer from IntelliJ, you'll see the same result:
DemoApplication:
@SpringBootApplication
class DemoApplication
fun main(args: Array<String>) {
SpringApplication.run(DemoApplication::class.java, *args)
}
错误:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'DemoApplication' may not be final. Remove the final modifier to continue.
Offending resource: com.example.demo.DemoApplication
build.gradle:
buildscript {
ext {
kotlinVersion = '1.2.10'
springBootVersion = '1.5.10.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
testCompile('org.springframework.boot:spring-boot-starter-test')
}
推荐答案
修正了将IntelliJ的Kotlin升级到1.2.21: https://plugins.jetbrains.com/plugin/6954-kotlin/update/ 42501
Fixed upgrading IntelliJ's Kotlin pluging to 1.2.21: https://plugins.jetbrains.com/plugin/6954-kotlin/update/42501
这篇关于IntelliJ Idea 2017.3无法启动Kotlin Spring Boot App - @Configuration类可能不是最终版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!