项目在idea中报错Command line is too long
Command line is too long. Shorten command line for SessionAnalysisJob or also for Application default configuration.
问题分析
这种异常的出现是因为运行项目的指令过长引起的,在IDEA进行代码运行时加载了很多指令,这些指令拼接后的长度超出了系统的最大长度,当你的命令行长度超过 32768 个字符时,idea就会提示你使用短一点的命令行。
大家可以在运行项目是看一下console输出的第一行日志,一般就是你的运行conmand
解决办法:
方式一:
在项目/.idea/workspace.xml文件中添加一行代码如下
<component name="PropertiesComponent">
...
<property name="dynamic.classpath" value="true" />
</component>
方式二:
在项目配置的运行参数配置中可以选择短命令行运行即Shorten command line
依次执行run–>edit configurations–>项目–>configuration–>Environment
在此条目下选择Shorten command line默认选择的是user-local default:none
这里有三个选项:
none
classpath file
jar manifest
此处可以选classpath file或者jar manifest运行项目也可解决此问题。