java 如何在 IDEA 中定义默认的 JVM 参数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32484449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 20:16:27  来源:igfitidea点击:

How to define default JVM arguments in IDEA?

javaintellij-ideajvm-arguments

提问by Philipp Cla?en

Is there an option to define default JVM arguments in IntelliJ IDEA?

是否可以选择在 IntelliJ IDEA 中定义默认 JVM 参数?

For example, I would like to always activate:

例如,我想始终激活:

  • -ea -Dslf4j.detectLoggerNameMismatch=true
  • -ea -Dslf4j.detectLoggerNameMismatch=true

In Eclipse, the option can be found in:

在 Eclipse 中,可以在以下位置找到该选项:

  • Preferences -> Java -> Installed JREs -> Edit -> Default VM arguments
  • 首选项 -> Java -> 已安装的 JRE -> 编辑 -> 默认 VM 参数

回答by yshavit

You have to do it per run type (Application, JUnit test, etc).

您必须按运行类型(应用程序、JUnit 测试等)执行此操作。

In the "edit configurations" window ("Run" ? "Edit Configurations..."), expand the "Defaults" item, select the appropriate run type, and edit its defaults in the left pane.

在“编辑配置”窗口(“运行”?“编辑配置...”)中,展开“默认值”项,选择适当的运行类型,并在左窗格中编辑其默认值。

The full documentation is available in the IDEA docs.

IDEA 文档中提供完整的文档

回答by OneWorld

This is the field in the Run/Debug Configurations dialog you need to edit:

这是您需要编辑的“运行/调试配置”对话框中的字段:

enter image description here

在此处输入图片说明

回答by Alz

You can set your VM options for all applications as a default by picking the application type (for command line Java programs it would be 'Application') under the 'Templates' tree found via the menu items Run/Edit Configurations... Then all new applications you create will use that default. Older versions of IntelliJ IDEA labeled that tree 'Defaults'.

您可以将所有应用程序的 VM 选项设置为默认值,方法是在“模板”树下通过菜单项“运行/编辑配置...您创建的新应用程序将使用该默认值。旧版本的 IntelliJ IDEA 将该树标记为“默认值”。