Solve the problem of Error running XXXApplicationCommand line is too long.

Tested IDEA version: 2019.2.4, 2020.1.3



Insert image description here


1. Problem Scenario

When we pull the project code from GitHub or the company's own git repository, the following error will occur

Insert image description here

The error code is as follows:

Error running "YxOaDataApplication": Command line is too long. Shorten command line for Yx0aDataApplication or also for Spring Boot default confiquration


2. Reason for error reporting

该问题是由于命令行过长导致的`

2.1 Why does a command line that is too long cause this problem?

This is caused by the operating system having certain restrictions on the length of the command line . Different operating systems and environments may have different restrictions on the length of the command line.

The command line length limit is to ensure that the operating system can correctly parse and execute command line parameters. When the command line exceeds the maximum length limit defined by the system, the operating system will report a command line too long error.

Here are some common reasons why command lines are too long:

  1. 参数过多: If a large number of parameters are passed in the command line, such as file paths, options or flags, etc., the length of the command line will be increased.
  2. 长路径: Using long file paths, directory paths, or paths containing multiple levels of nesting can also cause the command line to become very long
  3. 大量依赖项: If the application depends on many libraries, modules, or plugins, and these dependencies need to be passed to the application through command line parameters, the command line length may increase
  4. 配置项过多: Some applications may have a large number of configuration options that need to be passed through the command line, thereby increasing the length of the command line

3. Solution

Take the startup configuration item of ServiceStatisticsApplication in the local project as an example

3.1 Option 1

step:

① Locate the startup configuration item (xxxApplication) that reported the error in the project, and click its drop-down icon "v" —> "Edit Condiguration"

Insert image description here

②In the Run/Debug configuration interface, click "Configuration" --> "Environment" --> "Shorten command line" --> Select "JAR manifest" or "classpath file" in order to shorten the command line

Insert image description here

③Restart the module that reported the error in the project

shortcoming

If this problem occurs in other modules in the project, you also need to make the above settings for the startup configuration of the module in which the problem occurs. That is, the startup configuration of the next problematic module needs to be set separately .

3.2 Option 2

step:

In the .idea/workspace.xml file of the project, find it <component name="PropertiesComponent">and add a line afterwards<property name="dynamic.classpath" value="true" />

The code example is as follows:

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

Insert image description here

Advantage

This solution can be set up once, and there is no need to set it separately in the startup configuration items of each module in the project.


Guess you like

Origin blog.csdn.net/siaok/article/details/132158188