Command line is too long

这篇具有很好参考价值的文章主要介绍了Command line is too long。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

一、遇到的问题

二、使用环境

三、问题分析

四、解决方案

1、解决方式一

2、解决方式二


一、遇到的问题

上周五,我要改造一个之前从未接触过的 SpringBoot 项目。我用 git 拉下代码后,试图使用 Idea 运行它。但是,Idea 在运行时抛出了一个问题:Error running 'Application': Command line is too long. Shorten command line for Application or also for Application default configuration?

该问题一般会在新项目或者从未接触过的项目上出现。虽然网上有很多的解决方案,但很多解决方案都已经过时。并且这些方案也没有讲清问题的原因,所以我打算先用一个简单的 SpringBoot 项目模拟出该问题,再解决它,这样就很容易分析该问题。我觉得有必要写一篇文章记录这个过程,也可以帮助到遇到该问题的开发者。

Command line is too long

二、使用环境

我使用的操作系统是 Windows, Idea 的版本是:IntelliJ IDEA 2020.3.1 (Community Edition)

如果你遇到了该问题,先看一下你使用的 Idea 是多少版本的。2017.3 及以后的版本都可以使用该方法解决问题,如果你是 2017.3 之前的版本,我建议你升级 Idea ,尽量使用新版本的 Idea 。

Command line is too long

三、问题分析

我先问一个问题,在 Idea 中点击运行按钮后,Idea 会调用哪些命令?

当我们点击运行程序的按钮,Idea 会先调用 javac 命令编译程序,再调用 java 命令运行程序。

现在,分析一下错误:Error running 'Application': Command line is too long 。这个错误说的很明确,运行程序时报错,命令行太长了,而运行程序的命令就是上面说的 java 命令。最后的结论是,运行 java 的命令行太长。一般来说,操作系统有命令行长度限制,超过限制的长度就会执行失败。

下面来证明我的结论,在 Idea 中运行程序,控制台中打印的第一行日志如下图中红框所示:

Command line is too long

Command line is too long

该行日志就是使用 java 命令运行程序,点开后可以看到后面跟有 -javaagent、classpath 等参数。如果 classpath 中包含的 jar 包过多,可能导致命令行过长。

四、解决方案

既然知道了是 java 命令行太长,导致运行程序失败。只要缩短命令行就可以解决该问题,Idea 2017.3 之后的版本提供了缩短命令行的配置。如下有两种解决方式,方式一和方式二的原理一样,都是配置缩短命令行。方式一和方式二的区别在于方式一是按步骤配置,方式二是快速配置。

1、解决方式一

先打开 Run/Debug Configurations 面板。再点击 Modify options ,选择 Shorten command line ,再选择 JAR manifest 或者 classpath file 就可以解决问题。

示意图如下所示:

Command line is too long

Command line is too long

Command line is too long

2、解决方式二

如果你的 Idea 弹出报错信息如下图所示,直接点击蓝色的 JAR manifest 或者 classpath file 可以快速配置,再次运行程序就不会再报错了。

Command line is too long文章来源地址https://www.toymoban.com/news/detail-422921.html

到了这里,关于Command line is too long的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • IDEA:Error running,Command line is too long. Shorten command line解决方案

    原因是启动命令过长 方案一: 1.在工程文件.idea目录下找到workspace.xml 2.find查询并定位到PropertiesComponent 3.添加代码行 或另一种形式 4.CTRL+S保存确定 方案二: 1.打开Edit Configurations 2.点击Modify options设置,勾选Shorten command line 3.在Edit Configurations界面下方新增的Shorten command line选项

    2024年02月12日
    浏览(29)
  • idea 启动报错 Command line is too long

    启动报错信息: Error running ‘Application‘: Command line is too long. 翻译过来就是:启动命令过长! 解决方案 1、点开项目启动配置项目; 2、 shorten command line 选项选择 JAR manifest 或者 classpath file 选项,点击 Apply 和 OK,然后重启项目; Error running test: Command line is too long 上面是运行

    2024年02月10日
    浏览(43)
  • IDEA:Error running,Command line is too long. 解决方法

    报错如下: 原因是启动命令过长。 解决方法: 1、打开Edit Configurations 2、点击Modify options设置,勾选Shorten command line 3、在Edit Configurations界面下方新增的Shorten command line选项中选择JAR manifest或classpath file 然后 Apply,OK 即可。

    2024年02月01日
    浏览(32)
  • Intellij IDEA运行报Command line is too long的解决办法

    想哭,vue前端运行起来,对应的后端也得起服务。 后端出的这个bug,下面的博客写的第二种方法,完整截图是下面这个。 ​​​​​​​​​​​​​​​​​​​​Intellij IDEA运行报Command line is too long的解决办法 - 知乎 (zhihu.com)​​​​​​​  ​​​​​​​    

    2024年02月14日
    浏览(27)
  • idea Error running Application. Command line is too long. Shorten the command line via JAR manifest

    idea内容太长报错 报错: Error running Application. Command line is too long. Shorten the command line via JAR manifest or via a classpath file and rerun. 解决方法: 点击“Edit Configurations...”   选择左边的一个应用,点击 “Modify options”   点击 “Shorten command line”  点击 “Jar mainfest”  点击“Apply” 依

    2024年02月12日
    浏览(33)
  • 启动springboot项目时命令行太长错误解决(Command line is too long)

    刚从git拉取的项目进行启动时报错,说命令行太长。 Error running ‘YudaoServerApplication’: Command line is too long. Shorten command line for YudaoServerApplication or also for Spring Boot default configuration. 1.选择项目配置项 2.选择 Configuration 菜单中的 Shorten command line 下拉框中的 JAR manifest 或者 classpat

    2024年02月12日
    浏览(37)
  • idea 中运行spring boot 项目报 Command line is too long的解决办法。

    在这里选择edit configures 选择shrten command line , 选择 jar manifest 运行即可。

    2024年04月12日
    浏览(28)
  • 解决使用git时遇到的“Filename too long“问题

    【问题】 :  git 命令操作提示Filename too long,一般是在windows下出现的问题。git可以创建4096长度的文件名,然而在windows最多是260。 【解决方案】 git bash命令窗口输入 –global或者system是该参数的使用范围,只想对本版本库设置该参数,上述命令中去掉–global或system。

    2024年02月08日
    浏览(33)
  • 遇到“c++: 错误:unrecognized command line option ‘-std=c++17’”,CentOS升级GCC版本以支持c++17

    编译时遇到问题: c++: 错误:unrecognized command line option ‘-std=c++17’ 原因:GCC版本太低(CentOS7直接yum安装的GCC版本为4.8.5) 参考:Linux怎样更新Centos下Gcc版本支持C++17? 解决方案: 了解GCC版本及对C++版本的支持情况: GCC Releases GCC版本对C++的支持情况 C++ Standards Support in GCC 其

    2024年02月09日
    浏览(29)
  • goland报错:“package command-line-arguments is not a main package”解决方案

    大家好!我是躺平哥。         今天模拟客户端和服务端交互时遇到了一个问题: “package command-line-arguments is not a main package”          翻译过来就是包命令行参数不是主包         因为在Go语言中,和java的main是有所区别的,具体区别如下:         在java中,任何

    2023年04月19日
    浏览(24)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包