Intellij Idea 如何在IntelliJ中为整个项目配置“缩短命令行”方法

sxpgvts3  于 2022-11-28  发布在  其他
关注(0)|答案(9)|浏览(432)

当我运行测试时,我得到错误“命令行太长”。如果我在运行/调试配置中为特定的方法或类将“Shorten command line”方法设置为“JAR manifest”,它就可以工作,但是我如何为整个项目设置它呢?

rks48beu

rks48beu1#

在.idea文件夹中,更改workspace.xml文件
新增

<property name="dynamic.classpath" value="true" />

<component name="PropertiesComponent">
.
.
.
  </component>

范例

<component name="PropertiesComponent">
    <property name="project.structure.last.edited" value="Project" />
    <property name="project.structure.proportion" value="0.0" />
    <property name="project.structure.side.proportion" value="0.0" />
    <property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
    <property name="dynamic.classpath" value="true" />
  </component>

如果您没有看到,请自行添加

<component name="PropertiesComponent">
    <property name="dynamic.classpath" value="true" />
  </component>

社群编辑:此解决方案似乎无法在较新版本的IDE中工作,PropertiesComponent的格式现在不同了。如果是这种情况,则this answer应该可以工作

5kgi1eie

5kgi1eie2#

2018年2月5日
运行=〉编辑配置=〉选择左手的节点=〉展开环境=〉缩短命令行选项=〉选择类路径文件或JAR清单

zlhcx6iw

zlhcx6iw3#

通过更改缺省得JUnit运行/调试配置模板,可以设置缺省方式来缩短命令行,并将其用作进一步配置得模板.然后,在项目中创建得所有新运行/调试配置都将使用相同得选项.
下面是related blog post关于可配置命令行缩短器的选项。

qcbq4gxm

qcbq4gxm4#

默认情况下,最新的2020版本没有shorten命令行选项,我们需要从配置中添加该选项。

    • 运行〉编辑配置〉选择相应的运行配置**,然后单击修改选项以将shorten命令行配置添加到UI。
    • 选择缩短命令行选项**
    • 现在从shorten命令行选项中选择jar清单**
zkure5ic

zkure5ic5#

感谢Rajesh Goel在Android Studio
运行〉编辑配置...

选择一个测试(最好选择一个父测试类),并将Shorten command line:选项设置为classpath file。然后单击OK(或应用,确定)。

kiz8lqtg

kiz8lqtg6#

如果您使用的JDK版本为9+,则应选择

    • 运行**〉编辑配置...〉选择JUnit模板。

然后,选择**@argfile(Java 9+)**,如下图所示。

如果您没有看到Shorten命令行,则只需单击Modify options菜单(如下所示),并选择Shorten命令行

请尝试一下。祝你好运朋友。

9w11ddsr

9w11ddsr7#

<property name="dynamic.classpath" value="true" />添加到.idea/workspace.xml文件的<component name="PropertiesComponent">标签下。

46scxncf

46scxncf8#

按照以下步骤操作,并从shorten命令行类别中给出的下拉列表中选择“classpath.file”选项。

e4eetjau

e4eetjau9#

在我的例子中,错误是:

Error running 'MasterFileGenerator':
Command line is too long. Shorten command line for StagingFileGenerator or also for Application default configuration.

解决方案是切换到“Run/Debug Configurations”(运行/调试配置),然后从user-local default: none - java [options] className [args]切换到JAR manifest - java -cp classpath.jar className [args]

相关问题