文章目录
1. 复现错误
今天启动spring boot
项目时,却出现如下错误:
Error running ‘Application’: Command line is too long. Shorten command line for SpringBootMainApplication or also for Spring Boot default configuration
2. 分析问题
将Error running ‘Application’: Command line is too long. Shorten command line for SpringBootMainApplication or also for Spring Boot default configuration
错误,翻译成中文,如下图所示:
通过翻译后的报错信息来看,可知是命令行太长的原因导致SpringBoot
和整个应用无法成功启动,那为什么会报这样一个错误呢?
其实IDEA
底层是通过命令行或者文件的方式将classpath
传递到Java
的JVM
虚拟机上的,而大多数的操作系统都会有命令行的最大长度限制,超过这个限定值时就会导致IDEA
无法启动当前程序。
当命令行长度大于32768
个字符时,将IDEA
切换到动态类路径。长类路径被写入文件,然后由应用程序启动器读取并通过系统类加载器加载。
3. 解决错误
按修改命令行的方式,shorten command line 选项选择 JAR manifest
或者 classpath file
选项,最后apply