我遇到了一个问题,使用Spring Initializr创建的模板在运行bootRun时无法启动
发生的事情
Spring Initializr
初创应用初始化器
创建模板并下载。
-
- Generate a [Gradle Project] with [Kotlin] and Spring Boot [1.5.10]
-
- Project Metadata [com.example] [demo]
- Dependencies [Web] [Thymeleaf]
执行bootRun
./gradlew bootRun
为什么会出现java.lang.ClassNotFoundException导致崩溃。
应对
删除了build.gradle中的org.jetbrains.kotlin:*后,就可以正常工作了。
由于我另一个时间下载的模板中没有org.jetbrains.kotlin:*,而且还能正常运行,所以我将其删除了。
- 修正前
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:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
testCompile('org.springframework.boot:spring-boot-starter-test')
}
- 修正後
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')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
暂时能够运行,但为何能运行还不清楚,之后需要调查一下。