错误:Error running ‘xxx项目’: Command line is too long. Shorten command line for xxx or also for Spring Boot default configuration.
问题原因:
IDEA启动项目的时候是使用命令启动的。启动命令会输出在日志控制台的第一行,双击可展开显示全部命令。这个命令特别长,在windows系统中当超过32767个字符,就会报错!
解决方案1:
1.在IDEA中找到 Run-> Edit Configurations打开
2.在 Environment-> Shorten command line 的内容配置为 JAR即可解决:
使用这种解决方案时,遇到过其他问题,(在NacosWatch.java
文件中的public void stop() {}
方法中,报错Failed to stop bean ‘nacosWatch’。不同版本的spring依赖可能报错信息不一样)。
解决方案2:
在项目/.idea/workspace.xml文件中添加一行代码如下
<component name="PropertiesComponent">
<property name="dynamic.classpath" value="true" />
</component>
推荐这种方式,目前没遇到过问题。