IDEA 出现问题:Error running,Command line is too long. Shorten command line解决方案

https://blog.csdn.net/shi_hong_fei_hei/article/details/112634586

Intellij IDEA使用教程相关系列 目录

运行测试类报错

Error running ‘MallTest.testRun’: Command line is too long. Shorten command line for MallTest.testRun.
错误运行的测试。命令行太长。缩短命令行。
在这里插入图片描述

错误原因
出现这个的原因一般是因为项目需要打印的环境变量太长,超过了限制,需要你缩短命令行来解决问题。

解决办法

  1. 修改运行配置Configurations,将默认的Shorten command line的值user-local default 改为 JAR mainifest 或者 classpath file
    这种办法每次需要对每个类单独设置。
    在这里插入图片描述
  2. 在项目的.idea/workspace.xml文件中,找到
    <component name="PropertiesComponent">,后面在添加一行<property name="dynamic.classpath" value="true" />
    这种方式一次设置就行。