IDEA-解决Command line is too long. Shorten command line for SpringBootMainApplication or also for App

在IDEA 启动项目的时候 如果报以下错误 对应的修复方案

Error running ‘Application’:
Command line is too long. Shorten command line for SpringBootMainApplication or also for Application

 

 

1、原因

命令行太长的原因导致SpringBoot整个应用无法成功启动。其实IDEA底层是通过命令行或者文件的方式将classpath传递到Java的JVM虚拟机上的,而大多数的操作系统都会有命令行的最大长度限制,超过这个限定值时就会导致IDEA无法启动当前程序。当命令行长度大于32768个字符时,将IDEA切换到动态类路径。长类路径被写入文件,然后由应用程序启动器读取并通过系统类加载器加载。

 

2、解决

(1) 找到项目目录下的.idea\workspace.xml文件

 

 

(2) 找到workspace.xml文件下的PropertiesComponent标签栏

 

 

(3) 在PropertiesComponent标签栏内添加如下代码

<property name="dynamic.classpath" value="true" />

该配置的主要功能就是开启IDEA的动态类路径,将太长的类路径写入文件,然后由应用程序启动器读取并通过系统类加载器加载。具体实现可以查看IDEA社区版源代码,JdkUtil.java文件,setupJVMCommandLine方法。

 

参考搬运:(5条消息) IDEA-解决Command line is too long. Shorten command line for SpringBootMainApplication or also for App_Techyu的博客-CSDN博客

 

posted @ 2022-04-11 09:20  coder_Fish  阅读(458)  评论(0)    收藏  举报