如何在 IntelliJ IDEA 中设置 JVM 参数?

How to set JVM arguments in IntelliJ IDEA?

我对使用 Kinesis Video Stream 时的说明感到困惑

Run DemoAppMain.java in ./src/main/demo with JVM arguments set to

-Daws.accessKeyId={YourAwsAccessKey} -Daws.secretKey={YourAwsSecretKey} -Djava.library.path={NativeLibraryPath}

for non-temporary AWS credential.

如何在 IntelliJ IDEA 中设置这些参数?

Intellij 允许您在 运行 运行 Java 程序时指定两种类型的参数:

  • 虚拟机选项
    • 使您能够修改 JVM 的属性,包括stack/heap内存分配、系统属性、GC 标志等
  • 程序参数
    • 程序开始时,此处输入的值将传递到主方法的 String[] 参数中。

在上图中,我们指定了一个名为 example 的系统 属性(在 VM 选项下),其值为 Hello World!

我们还指定了两个程序参数(在程序参数下):HelloWorld!

单击 Apply 按钮或 OK 按钮后,我们可以 运行 以下程序:

public static void main(String[] args) {
    System.out.println(System.getProperty("example"));
    System.out.println(args[0] + " " + args[1]);
}

这个程序的输出如下:

Hello World!
Hello World!

要创建 Run/Debug 配置,请参阅:Create and Edit Run/Debug Configurations

去编辑配置并把

-Dserver.port=9006(required port no) 

在 VM 选项中:并应用和 运行,它将起作用

如果您有 2021.1.1 社区版本,请按照以下步骤操作: