IDEA maven 项目(spring boot):找不到或无法加载主类 || ## Disconnect to the target VM, address: ‘127.0.0.1:xxxxx’, transport: ‘socket’ || Process finished with exit code -1
我在使用IDEA运行springboot框架的maven项目时,选择debug xxxxxx.class
后,出现了如下的问题。
可能的原因:
(1)maven与idea版本不兼容
(2)端口号被占用
(3)程序中设置了断点
解决方案汇总:
一般来说,Process finished with exit code -1是端口号被占用的问题。我在第一次遇到这个bug时,发现启动项目所需要的8080端口被占用,使用taskkill /pid xxxx -f -t命令即可解决问题。
第二次遇到这个问题时,我已经毙掉了8080端口占用的进程,然而maven项目依然无法运行,bug如上图。我的解决方案是:Run Maven -> clean->validate->compile->test->package->verify->insatll。之后debug启动,启动成功。
解决过程中的其他方案:可以尝试安装jRebel插件,然后选择rebel debug,会有debug日志文件产生。通过看日志解决问题。此处可见另一篇博客(链接找不到了)