【解决错误】IDEA启动SpringBoot项目 出现:Command line is too long
复现错误
今天启动spring boot项目时,却出现如下错误:
Error running ‘RiskmgtApplication’: Command line is too long. Shorten command line for RiskmgtApplication
分析问题
Error running ‘RiskmgtApplication’: Command line is too long. Shorten command line for RiskmgtApplication
翻译成中文大体意思就是运行RiskmgtApplication时报错了:命令行太长了,用短命令行运行RiskmgtApplication
其实IDEA底层是通过命令行或者文件的方式将classpath传递到Java的JVM虚拟机上的,而大多数的操作系统都会有命令行的最大长度限制,超过这个限定值时就会导致IDEA无法启动当前程序。
当命令行长度大于32768个字符时,将IDEA切换到动态类路径。长类路径被写入文件,然后由应用程序启动器读取并通过系统类加载器加载。
解决错误
按修改命令行的方式,shorten command line 选项选择 JAR manifest 或者 classpath file 选项,最后apply
-
JAR manifest:将类路径信息存储在JAR文件的MANIFEST.MF中。
-
classpath file:将类路径信息存储在一个单独的文件中。