如何修复调试中的 ClassNotFoundException: kotlinx.coroutines.debug.AgentPremain?

Léo*_*der 21 intellij-idea kotlin

我正在运行几个项目作为 Spring Boot 应用程序,其中一个项目特别无法启动并抛出:

java.lang.ClassNotFoundException: kotlinx.coroutines.debug.AgentPremain
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:304)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Exception in thread "main" FATAL ERROR in native method: processing of -javaagent failed
Disconnected from the target VM, address: '127.0.0.1:64279', transport: 'socket'

Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)

命令行有选项:

-javaagent:[...].m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.5.0/kotlinx-coroutines-core-1.5.0.jar
Run Code Online (Sandbox Code Playgroud)

这个罐子是存在的。

将我的 Intellij'Idea 更新到 2021.2 后发生这种情况

此问题仅在调试模式下发生。

知道如何解决这个问题吗?

小智 48

这是 Kotlin 插件中的一个已知问题。作为解决方法,禁用 下的协程代理选项Settings/Preferences | Build, Execution, Deployment | Debugger | Data Views | Kotlin | enable "Disable coroutine agent"

请关注https://youtrack.jetbrains.com/issue/KTIJ-19345获取更新。

在此输入图像描述

  • 该票证表明此错误已修复。但事实并非如此。该bug在IntelliJ 2021.3中仍然出现 (3认同)

小智 9

较新版本的 IntelliJ 在下面有此选项Settings/Preferences | Build, Execution, Deployment | Debugger

在此输入图像描述