购买
下载掌阅APP,畅读海量书库
立即打开
畅读海量书库
扫码下载掌阅APP

1.3 Spring Boot编译后可能遇到的问题

本节将对Spring Boot编译后可能遇到的问题进行说明,并提供相应的解决方法。

在启动smoketest.propertyvalidation.SamplePropertyValidationApplication的时候可能会出现启动失败的问题(并非特指SamplePropertyValidationApplication,其他应用启动类也有可能出现此问题),具体现象是普通启动在IDEA编辑器中并未出现问题,当通过debug启动时在IDEA中出现了报错。关于报错的异常堆栈信息如下:

    java.lang.NoClassDefFoundError:kotlin/Result
        at kotlinx.coroutines.debug.AgentPremain.<clinit>(AgentPremain.kt:24)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.
java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.
java:386)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.
java:401)
    Exception in thread "main" FATAL ERROR in native method:processing of -javaagent
failed

关于这个问题笔者在Spring Boot的GitHub仓库提了一个Issues,具体地址是https://github.com/spring-projects/spring-boot/issues/27531。在和Spring Boot项目成员交流后得出了如下解决方案。在IDEA中打开设置界面,依次选择Build,Execution,Deployment → Debugger →Data Views → Kotlin选项,进入之后会看到如图1-5所示的内容。

图1-5 IDEA Kotlin配置

注意在IDEA默认状态下Disable coroutine agent是没有选中的,此时需要选中此选项,修改成功后单击Apply按钮和OK按钮完成配置。通过上述配置处理后再进行debug启动就不会遇到本节最开始的问题了。 wwZzXnAWgdUgXNXg4YtA7ew9tIbA71BWLsjapPePGEbWu373cv/PJXerIWg79Knh

点击中间区域
呼出菜单
上一章
目录
下一章
×