A wonderful problem when IDEA uses java development

Using Idea to run the project reports an error when the project starts:

Command line is too long. Shorten command line for XXXApplication or also for Spring Boot default configuration.

I thought it was the problem of Command line is too long., but the result can only be used

problem analysis

This kind of exception occurs because the command to run the project is too long. When IDEA runs the code, a lot of commands are loaded. The length of these commands after splicing exceeds the maximum length of the system. When the length of your command line exceeds 32768 characters , idea will prompt you to use a shorter command line.

You can look at the first line of log output by the console when running the project. Generally, your running command executes run–>edit configurations–>your project–>configuration–>Environment

But the solution needs to be configured individually every time, and junit needs to be configured individually every time it is used . Isn’t it necessary to configure four

But open the dynamic path in idea's .idea/workspace.xml. This method does not work because the project does not have an .idea file

Searching for half a day to find the solution to the problem (written at the end)

problem solved

method one:

Enable the dynamic path in idea's .idea/workspace.xml.

in workspace.xml

Add properties under the <component name="PropertiesComponent"> entry

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

The idea can be used to find the project path through the dynamic path during execution, the specific implementation principle, but you can view the source code of the idea community version.

Method two:

In the running parameter configuration of the project configuration, you can choose a short command line to run, that is, Shorten command line

Execute run–>edit configurations–>your project–>configuration–>Environment in turn

在此条目下选择Shorten command line默认选择的是user-local default:none

这里有三个选项:

none

classpath file

jar manifest

此处可以选classpath file或者jar manifest运行项目也可解决此问题

写在最后

当改了配置后我们可以看一下我们的conmand line情况

D:\work\jdk1.8.0_101\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:57607,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:C:\Users\jonas\AppData\Local\JetBrains\IntelliJIdea2020.2\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath C:\Users\jonas\AppData\Local\Temp\classpath1326103414.jar com.xxx.service.order.admin.ServiceOrderAdminApplication

1

可以看到应用启动的时候是有加载jmx的,我这里把jmx关一下,看一下是否能正常运行。

运气不错,关闭jmx后,项目运行起来了,但是运行的conmand line的长度真的是让人感动,之前那还怀疑真的会有那么长的命令行么,还真的有,以下为默认的启动命令行。

可以看到默认的启动时会把所有依赖jar报的路径也加上,这个真的是可怕。

解决办法

因为项目是从svn下载的,导入时项目文件夹是在一个总文件夹中,而编写代码时只显示项目文件夹,

但是.idea在总文件夹中,要么

方法1.重新导入文件以项目文件夹导入idea,idea会自动创建.idea。但是这样又得重新配置项目相关project Structure,那岂不是要配四

方法2.看图

改即可。

Guess you like

Origin blog.csdn.net/qq_27246521/article/details/128913122