出现Error running 'SystemApplication' Error running SystemApplication. Command line is too long. Shorten the command line via JAR manifest or via a classpath file and rerun.
时间: 2025-06-05 08:35:46 浏览: 21
### 解决方案概述
在使用 IntelliJ IDEA 启动项目时,如果出现 `Error running 'SystemApplication': Command line is too long` 的错误提示,可以采取以下措施来解决。该问题通常是由于传递给 JVM 的命令行参数过长导致的,可以通过调整项目的运行配置来缩短命令行长度。
---
### 具体解决方法
#### 方法一:通过 JAR Manifest 缩短命令行
1. 在 IntelliJ IDEA 中打开项目的运行/调试配置页面。
- 点击顶部菜单栏中的 **Run** -> **Edit Configurations**[^3]。
2. 在弹出的窗口中,选择左侧列表中报错的服务或应用(例如 `SystemApplication`)。
3. 在右侧的配置选项中,找到 **Shorten command line** 下拉框。
4. 将其值更改为 **JAR manifest**[^3]。
5. 点击 **Apply** 按钮保存更改,然后点击 **OK** 关闭窗口。
6. 重新启动服务以验证问题是否解决。
#### 方法二:通过 Classpath File 缩短命令行
1. 打开运行/调试配置页面(同上)。
2. 在 **Shorten command line** 下拉框中,选择 **Classpath file**[^2]。
- 此选项会将类路径信息写入一个临时文件,并通过该文件传递给 JVM,从而避免命令行过长的问题。
3. 点击 **Apply** 和 **OK** 保存设置。
4. 重启服务以检查效果。
#### 方法三:修改全局设置
如果希望对所有项目生效,可以修改 IntelliJ IDEA 的全局设置:
1. 打开 **File** -> **Settings**(Windows/Linux)或 **IntelliJ IDEA** -> **Preferences**(Mac)。
2. 导航到 **Build, Execution, Deployment** -> **Compiler** -> **Build Process**。
3. 找到 **Command-line option** 设置项,将其更改为 **JAR manifest** 或 **Classpath file**。
4. 应用更改并重启 IDEA。
---
### 注意事项
- 如果项目是 Spring Boot 项目,确保在运行配置中正确指定了主类(Main Class)[^2]。
- 使用 **JAR manifest** 方式可能会稍微增加构建时间,因为需要生成额外的清单文件。
- 如果仍然遇到问题,可以尝试清理缓存:**File** -> **Invalidate Caches / Restart**。
---
### 示例代码:Spring Boot 运行配置
以下是 Spring Boot 项目的运行配置示例,确保主类和相关参数正确设置:
```properties
# application.properties 示例
server.port=8080
spring.application.name=system-application
```
```java
// 主类示例
package com.example.systemapplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SystemApplication {
public static void main(String[] args) {
SpringApplication.run(SystemApplication.class, args);
}
}
```
---
###
阅读全文
相关推荐










