Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on – Linux, macOS, and Windows.
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. It takes an opinionated view of the Spring platform and third-party libraries so one can get started with minimum fuss. Most Spring Boot applications need minimal Spring configuration.
- Spring Boot support in Visual Studio Code Spring Boot in Visual Studio Code Visual Studio Code is an ideal lightweight development environment for Spring Boot application developers and there are several useful VS Code extensions including.
- Spring Initializr Java. The Spring Initializr Java Support extension provides support for generating quickstart Spring Boot Java projects with Spring Initiailizr API. Spring Boot Dashboard. The Spring Boot Dashboard extension provides an explorer in the side bar where you can view all of a workspace's spring boot projects conveniently in one place. You can also quickly start, stop or debug a project.
- Java maven spring-boot visual-studio-code. Improve this question. Follow asked Apr 10 '17 at 11:38. Rodrigo5244 Rodrigo5244. 3,798 1 1 gold badge 20 20 silver badges 33 33 bronze badges. Add a comment 2 Answers Active Oldest Votes. You will only be able to.
Eclipse & IntelliJ IDEA are typically suggested for spring boot development.
I use VS Code for everything because it’s fast, lightweight, powerful & provides a rich user experience. Now that VS Code supports Java + Spring Boot development, here is how you can set it up too.
Setup for Java
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform.
VS Code works with all major versions of Java SE from 11.
Auto Setup
Visual Studio Code offers special installers for Java developers, which include all the necessary dependencies and extensions for Java development in Visual Studio Code as below.
- Windows:Installer of Visual Studio Code for Java developers
- macOS:Installer of Visual Studio Code for Java developers
Countdown timers online. The installer automatically tries to detect a JDK, VS Code, and essential Java extensions. During install, it downloads the stable versions of those tools from trusted online sources and then installs and configures them.
Manual Setup
Alternatively, you can install JDK, VS Code or extensions separately as per your preference as below.
- Download & install a Java SE Development Kit (JDK) from one of these sources
Oracle Java SE
AdoptOpenJDK
Azul Zulu for Azure – Enterprise Edition
- Install Visual Studio Code and enable Java support by installing the Microsoft Java Extension Pack extension.
- Tell VS Code where the JDK is located by setting the value of the JAVA_HOME system environment variable to the install location of the JDK. Alternatively, if you want to configure only VS Code to use the JDK, use the java.home setting in VS Code’s User or Workspace settings ( ⌘,).
Squeezed juice cleanse. Steps for setting JAVA_HOME varies for different versions of Windows & MacOS and is outside the scope of this article.
Setup for Spring Boot
To enable VS Code for Spring Boot development, install the following extensions.
Create the Project
Launch VS Code and open the command palette ( ⇧⌘P) and type Spring Initializr to start generating a Maven or Gradle project and then follow the wizard.
Edit the Project
Create a web controller by adding the following code to the src/main/java/com/example/demo/HelloController.java file.
HelloController.java
2 4 6 8 10 12 14 | importorg.springframework.web.bind.annotation.RestController; importorg.springframework.web.bind.annotation.RequestMapping; @RestController publicStringindex(){ } } |
Run the Project
What Is Visual Studio Code
Click F5 to run your application or use the Spring Boot Dashboard with which you can view and manage all available Spring Boot projects in your workspace as well as quickly start, stop, or debug your project.
References
Visual Studio Code is an ideal lightweight development environment for Spring Boot application developers and there are several useful VS Code extensions including:
If you run into any issues when using the features below, you can contact us by clicking the Report an issue button below.
Prerequisites
A working Java environment with essential extensions installed is needed, including:
- Java Development Kit (JDK), version 11 or later.
- Apache Maven, version 3.0 or later.
For more details, please refer to Java Tutorial
Note: More information about JDK can be found at supported Java versions.
Create the project
The Spring Initializr extension allows you to search for dependencies and generate new Spring Boot projects.
To install, launch VS Code and from the Extensions view (⇧⌘X (Windows, Linux Ctrl+Shift+X)), search for
vscode-spring-initializr
.Once you have the extension installed, open the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and type
Spring Initializr
to start generating a Maven or Gradle project and then follow the wizard.Edit the project
The Spring Initializr extension allows you to edit dependencies after generating a new Spring Boot project.
Navigate to your
pom.xml
file and right-click to select Edit starters
. The Command Palette will show the dependencies you already have beginning with a √
. You can search for other dependencies you want to add to your project. Or you can click on the existing dependencies to remove them.Develop the application
Visual Studio Code Tutorial
The Spring Boot Tools extension includes rich language support for working with Spring Boot
application.properties
, application.yml
, and .java
files.The extension supports quick navigate through source code, smart code completions, quick access to running apps, live application information, and code templates. Similar code completion and validation features are also available for
.properties
and .yml
files.Run the application
In addition to click F5 to run your application, there's another convenient extension Spring Boot Dashboard with which you can view and manage all available Spring Boot projects in your workspace as well as quickly start, stop, or debug your project.
Next steps
- To deploy your web app, see the Deploy a Java Application to Azure tutorial.
- To containerize a web app and deploy as a Docker container, check out the Working with Docker.
- To learn more about Java Debugging features, see Java Debugging Tutorial.