Intellij IDEA 运行前报错 Command line is too long

报错内容

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

解决方法

修改项目下 .idea\workspace.xml,找到标签

<component name="PropertiesComponent">

在标签里加一行

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

如下图所示:

<component name="PropertiesComponent">
  <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
  <property name="last_opened_file_path" value="$PROJECT_DIR$/src/test/java/com/XXX/util" />
  <property name="project.structure.last.edited" value="Global Libraries" />
  <property name="project.structure.proportion" value="0.0" />
  <property name="project.structure.side.proportion" value="0.2" />
  <property name="dynamic.classpath" value="true" />
</component>