Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Spring arguments to VSCode Debug launch.json

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.

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

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"
        ]
    }
]}
like image 792
DJ House Avatar asked Feb 27 '19 14:02

DJ House


1 Answers

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.

Updated file:

{"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"
        ]
    }
]}
like image 197
DJ House Avatar answered Sep 24 '22 01:09

DJ House