I am trying to run Spring Boot Application in a Visual Studio Code with the RedHat Java extension. I am adding JVM args as shown below in the launch.json.
{
"configurations": [
{
"type": "java",
"name": "Application",
"request": "launch",
"mainClass": "com.Application",
"projectName": "Application",
"vmArgs": [
"-Dserver.port=8081",
"-DPROJECT_NAME=AAA",
"-DAPP_NAME=AAA",
"-DUSER_ROLE="
]
}
]
}
One of the argumnet is USER_ROLE that needs to be a json string. Example, USER_ROLE: {"USER":{"ROLE":"DEVELOPER"}}
I am facing problem while putting this value in the list of vmargs in launch.json.
I have tried different approaches.
Example1, "-DUSER_ROLE={\"USER\":{\"ROLE\":\"DEVELOPER\"}}"
Example2, "-DUSER_ROLE={\\\"USER\\\":{\\\"ROLE\\\":\\\"DEVELOPER\\\"}}"
After running the App, this are the values getting passed to the variable.
Example1, {\USER\\:{\ROLE\\:[\DEVELOPER\\}}
Example2, {\\\USER\\\\\\:{\\\ROLE\\\\\\:[\\\DEVELOPER\\\\\\}}
Quotations are getting ignored. Please help me out with this. I am able to use other IDEs but wanted to try VS Code. I also wanted to know if this is a best practice to add vmargs. Please let me know if there's better way.
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "BuilderApplication",
"request": "launch",
"mainClass": "com.BuilderApplication",
"projectName": "builder",
"env": {
"FIRST_ARG": "{\"user\":{\"role\":[\"developer\"]}}"
},
"vmArgs": [
"-D2nd_ARG=",
]
}
]
}
I was able to configure the launch.json as shown above to fix the issue I had. I had to make use of vmArgs as well in this because env was not supporting empty argument.
Although I switched to STS (easy and simple), this workaround is usable if you want to use VSC.