Command line is too long的解决办法

Posted 张侦毅

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Command line is too long的解决办法相关的知识,希望对你有一定的参考价值。

  本人用IDEA启动一个新的项目,在项目启动时,出现下面的故障码:

Error running 'Application';
Command line is too long.Shorten command line for Application or also for Spring Boot default configuratin.

  于是启动失败。

  后来经过排查,发现idea在项目启动时其实是执行了如下的命令行:

"C:\\Program Files\\RedHat\\java-1.8.0-openjdk-1.8.0.212-3\\bin\\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\\Dev\\IDE\\IDEA\\IntelliJ IDEA 2018.3.5\\lib\\idea_rt.jar=51042:D:\\Dev\\IDE\\IDEA\\IntelliJ IDEA 2018.3.5\\bin" -Dfile.encoding=UTF-8 -classpath C:\\Users\\Dell\\AppData\\Local\\Temp\\classpath443986179.jar com.xxx.Application

  由此我们得知,正是由于该命令行超长,因而触发了IDEA的启动报错,解决办法是将其改为动态类路径

  在项目的根目录下的.idea/workspace.xml文件中的<component name="PropertiesComponent">下添加如下代码:

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

  之后再次启动,问题解决。

以上是关于Command line is too long的解决办法的主要内容,如果未能解决你的问题,请参考以下文章