IntelliJ IDEA调试Spring Boot时遇ClassNotFoundException: AgentPremain
解决IntelliJ IDEA社区版调试Spring Boot时kotlinx.coroutines.debug.AgentPremain找不到的问题
错误信息
Connected to the target VM, address: '127.0.0.1:57235', transport: 'socket' Exception in thread "main" java.lang.ClassNotFoundException: kotlinx.coroutines.debug.AgentPremain at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:431) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525) *** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at ./src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422 FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed Disconnected from the target VM, address: '127.0.0.1:57235', transport: 'socket'
替代解决方案(针对社区版找不到Data Views下Kotlin选项的情况)
方法一:移除协程调试代理参数
打开IDEA的「Run/Debug Configurations」,找到你的Spring Boot启动配置,在「VM options」中删除包含-javaagent:...kotlinx-coroutines-agent...的参数,保存后重新启动调试。方法二:添加协程调试依赖
如果需要保留协程调试功能,在项目依赖中添加kotlinx-coroutines-agent:
Maven项目(pom.xml):<dependency> <groupId>org.jetbrains.kotlinx</groupId> <artifactId>kotlinx-coroutines-agent</artifactId> <version>你的协程对应版本</version> <scope>runtime</scope> </dependency>Gradle项目(build.gradle):
runtimeOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-agent:你的协程对应版本'注意替换为项目中已使用的kotlinx-coroutines版本,保证版本一致。
方法三:升级或调整IDEA版本
尝试将IntelliJ IDEA社区版升级至较新版本,部分旧版本社区版可能存在功能选项缺失的情况。
内容的提问来源于stack exchange,提问作者Aymen Kanzari
相关产品推荐
相关产品推荐

