【问题标题】:Adding Spring arguments to VSCode Debug launch.json将 Spring 参数添加到 VSCode Debug launch.json
【发布时间】:2019-07-21 08:07:27
【问题描述】:

我正在使用 VSCode 中的 Java Springboot (2.1.2) 应用程序。我有调试器工作并且可以运行应用程序。但是,我很难将特定于 Spring 的参数添加到运行命令中。我环顾四周,但似乎找不到任何东西。

我试图告诉 spring 使用两个 application.yml 文件。我将在命令行中实际运行应用程序的代码是:

mvn spring-boot:run \ -Dspring.config.location=classpath:/application.yml,classpath:/application-secret.yml

我希望能够将此参数添加到 vscode launch.json 文件中。

我当前的启动文件看起来像这样,但我尝试了很多不同的变体。

{"version": "0.2.0",
"configurations": [
    {
        "type": "java",
        "name": "Debug Blog Rest",
        "request": "launch",
        "mainClass": "com.example.BlogRestApplication",
        "args": [
            "-Dspring.config.location=classpath:/application.yml,classpath:/application-secret.yml"
        ]
    }
]}

【问题讨论】:

    标签: java spring spring-boot visual-studio-code vscode-debugger


    【解决方案1】:

    其实我只是想通了。我以为我以前试过这个,但我想没有。我不得不将它从args 更改为vmArgs

    更新文件:

    {"version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug Blog Rest",
            "request": "launch",
            "mainClass": "com.example.BlogRestApplication",
            "vmArgs": [
                "-Dspring.config.location=classpath:/application.yml,classpath:/application-secret.yml"
            ]
        }
    ]}
    

    【讨论】:

      猜你喜欢
      • 2019-02-03
      • 2021-07-02
      • 2019-10-23
      • 2015-07-10
      • 2023-03-09
      • 1970-01-01
      • 2022-10-25
      • 1970-01-01
      • 2012-01-05
      相关资源
      最近更新 更多