【发布时间】:2019-01-27 05:41:15
【问题描述】:
我安装了Eclipse Photon 和Kotlin plugin for Eclipse 0.8.6 和Spring Tools 3.9.5.RELEASE 插件。我按照these 的说明使用向导创建了一个新项目:
然后我创建了一个新的Run Configuration 并按照参考中的说明编辑了主类:
运行项目后,我得到了这个错误:
Error: Could not find or load main class com.kotlinexample.KotlinExampleApplicationKt
Caused by: java.lang.ClassNotFoundException: com.kotlinexample.KotlinExampleApplicationKt
我检查了我的 build.gradle 和 this 文档,看起来还可以:
buildscript {
ext {
kotlinVersion = '1.2.51'
springBootVersion = '2.0.4.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'
apply plugin: 'io.spring.dependency-management'
group = 'com.kotlinexample'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
}
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-web')
compile('com.fasterxml.jackson.module:jackson-module-kotlin')
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compile("org.jetbrains.kotlin:kotlin-reflect")
runtime('com.h2database:h2')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
【问题讨论】:
-
你的 Kotlin 源码呢?
-
Kotlin plugin for Eclipse 0.8.6
标签: eclipse spring-boot kotlin