将 Spring 参数添加到 VSCode Debug launch.json [英] Adding Spring arguments to VSCode Debug launch.json
问题描述
我正在 VSCode 中使用 Java Springboot (2.1.2) 应用程序.我有调试器工作并且可以运行应用程序.但是,我在向 run 命令添加 Spring 特定参数时遇到了困难.我环顾四周,但似乎无法找到任何关于此的信息.
I am working with a Java Springboot (2.1.2) application in VSCode. I have the debugger working and can run the application. However, I am having difficulty adding Spring specific arguments to the run command. I have looked around alot but can't seem to find anything on this.
我试图告诉 spring 使用两个 application.yml 文件.我将在命令行中用于实际运行应用程序的代码是:
I am trying to tell spring to use two application.yml files. The code I would use in the command line to actually run the application is:
mvn spring-boot:run \-Dspring.config.location=classpath:/application.yml,classpath:/application-secret.yml
我希望能够将此参数添加到 vscode launch.json 文件中.
I want to be able to add this argument to the vscode launch.json file.
我当前的启动文件看起来像这样,但我尝试了很多不同的变体.
My current launch file looks like this, but I have tried alot of different variations.
{"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"
]
}
]}
推荐答案
实际上我只是想通了.我以为我以前试过这个,但我想没有.我不得不将它从 args
更改为 vmArgs
.
I actually just figured it out. I thought I had tried this before, but I guess not. I had to change it from args
to 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"
]
}
]}
这篇关于将 Spring 参数添加到 VSCode Debug launch.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!