IDEA-Command line is too long……错误
IDEA-解决Command line is too long. Shorten command line for SpringBootMainApplication or also for App
原文地址 blog.csdn.net
错误须看清楚,所以有时候不需要多次搜索即可解决问题,重要的是提升搜索关键字以及正确答案的筛选率
今天在使用 IDEA 启动一个开源项目的时候,报了一个错误。具体错误内容如下:
Error running ‘Application’:
Command line is too long. Shorten command line for SpringBootMainApplication or also for Application
查阅了下原因,但是一般的博客都仅仅是介绍了如何解决,问题的原因和为什么这样子解决都完全没有提及,下面我就查到的资料做下简单的分析。
问题分析
错误原因:
看报错的那段英文,可知是命令行太长的原因导致 SpringBoot 和整个应用无法成功启动,那为什么会报这样一个错误呢?
错误分析:
其实 IDEA 底层是通过命令行或者文件的方式将 classpath 传递到 Java 的 JVM 虚拟机上的,而大多数的操作系统都会有命令行的最大长度限制,超过这个限定值时就会导致 IDEA 无法启动当前程序。
错误解决:
当命令行长度大于 32768 个字符时,将 IDEA 切换到动态类路径。长类路径被写入文件,然后由应用程序启动器读取并通过系统类加载器加载。
具体解决步骤
Step1:找到项目目录下的. idea\workspace.xml 文件
具体位置如下图所示:
Step2:找到 workspace.xml 文件下的 PropertiesComponent 标签栏
Step3:在 PropertiesComponent 标签栏内添加如下代码
<property name="dynamic.classpath" value="true" />
该配置的主要功能就是开启 IDEA 的动态类路径,将太长的类路径写入文件,然后由应用程序启动器读取并通过系统类加载器加载。
具体实现可以查看 IDEA 社区版源代码,JdkUtil.java 文件,setupJVMCommandLine 方法。
链接如下: IDEA 源代码
- idea报错:Error running $classname: Command line is too long. Shorten command line for $classname.
- IDEA编译项目报错:Command line is too long
- 【bug】-idea启动报错 Command line is too long. Shorten command line for SampleApplication...
- Idea SpringBoot工程提示 "Error running 'xxxx'": Command line is too long... 问题解决
- IDEA命令行缩短器助你解决此问题:Command line is too long. Shorten command line...
- IDEA命令行缩短器助你解决此问题:Command line is too long. Shorten command line...
- Idea报错Command line is too long
- IDEA 启动项目报错:Error running 'Application': Command line is too long.
- idea报错:Error running $classname: Command line is too long. Shorten command line for $classname.
- IDEA使用实战:Error running $classname: Command line is too long. Shorten command line for $classname
- IDEA报错:Command line is too long.
- 解决IDEA启动时Command line is too long
- IDEA运行main方法报Command line is too long解决方法
- 异常处理 IDEA运行报Command line is too long解法
- Intellij IDEA运行报Command line is too long错误
- Intellij IDEA运行报Command line is too long
- Command line is too long. In order to reduce its length classpath file can be used 微服务启动出错
- Intellij IDEA运行报command line is too long. shorten command line for xxx 解法
- Command line is too long. Shorten command line for OOP or also for Application default configuration
- 【异常处理】Error running 'Application': command line is too long