Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code + Spring Boot Project change spring.properties.additional-location etc

Recently i decided to pass from Eclipse to VS Code , everything is running smoothly for Javascript development but for Spring Boot applications i don't know how to configure them here .

Except of the application.properties file i have one more extra local.properties which i use to run locally the Spring Boot Application .

I see there is a launch.json file :

{
    "configurations": [

        {
            "type": "java",
            "name": "CodeLens (Launch) - fmApplication",
            "request": "launch",
            "mainClass": "com.application.zz.app.fmApplication",
            "projectName": "file-manager"
        }
    ]
}

In Eclipse i am adding additional configuration to run my Spring Boot Application like shown below :

enter image description here

How can i do that is Vs Code :) ?

Here is the issue on Vs Code Github Page

like image 728
GOXR3PLUS Avatar asked Feb 27 '19 09:02

GOXR3PLUS


1 Answers

Unlike JavaScript, Java code needs to be compiled so it wont work out of the box with visual studio code since it's just a glorified text editor.

There are however multiple tools to accommodate for this, and the folks at VS code have a nice guide for setting you up - https://code.visualstudio.com/docs/java/java-spring-boot


Solution :

So you have an application.properties file and locally you have a application-local.properties(attention , you must name your local properties like that).

Then in your launch.json you add it to your program parameters :

"args": "--spring.profiles.active=local"

So your launch.json file will look like this for example :

{
  "configurations": [
    {
      "type": "java",
      "name": "CodeLens (Launch) - fmApplication",
      "request": "launch",
      "mainClass": "com.intralot.l10.app.fmApplication",
      "projectName": "file-manager",
      "args": "--spring.profiles.active=local"
    }
  ]
}
like image 116
Ivan Furdek Avatar answered Nov 14 '22 06:11

Ivan Furdek