Spring-Boot application run configurations with VScode

Eogcloud :

Within the Spring-Tools-suite (customised version of eclipse), there is an option to define multiple run configurations for the same application and then to run them.

For example, when testing a Eureka Server and running multiple instances of the same application with different port and name definitions to check registration.

Does anyone know of a method to define similar run configurations using Spring and Java Extensions with Visual Studio Code?

Jon Sampson :

In direct answer to your question, the function you may be looking for is:

Debugging with Launch Configurations

To debug a simple app in VS Code, press F5 and VS Code will try to debug your currently active file.

However, for most debugging scenarios, creating a launch configuration file is beneficial because it allows you to configure and save debugging setup details.

The documentation is quite extensive on that function. As in Eclipse this is built in relation to debugging (where launching the apps from within Eclipse don't necessarily attach to the debugger). You will be most familiar with Launch configurations (as opposed to Attach) which are analogous to Run Configurations. Add a new configuration illustrates how to build a launch.json file via snippets instead of via a wizard as with Eclipse.

launch.json wizard construction

Regarding Spring Boot specifically, Pivotal has a couple of extensions for you: Spring Boot Tools and Spring Initializr support which give you some extra functionality along with Launches.

Run Configurations and Launch configurations are good in a pinch, but as Leo Zhu mentioned in the comments, Maven profiles (Configure active profile in SpringBoot via Maven / docs) or Gradle's equivalent simple use of if statements to control environments (Maven profiles equivalent of Gradle / Gradle blog entry) are more portable and are IDE independent. These methods have my personal vote.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=125935&siteId=1