Spring Boot Environment Setup

Spring Boot Development Environment Setup

In this article, I am going to discuss How to Set up the Development Environment for Developing Spring Boot Application as well as we will also discuss how does Spring Boot Work? Please read our previous article where we discussed what is Spring Boot.

How Does Spring Boot Work?

The main feature of Spring Boot is that it automatically configures the program based on the dependencies added. This can be done using the @EnableAutoConfiguration keyword. For example, if MySQL is added as a dependency but an external database is not configured, Spring Boot automatically configures a database in memory. A starter package, such as spring-boot-starter-*, where * indicates a type of application, is used to add a dependency.

How to Use Autoconfiguration?

Spring Boot Starter Actuator dependency is used to monitor and manage the application. The dependency code for this is as follows:

How to Use Autoconfiguration?

The @EnableAutoConfiguration keyword is used as follows:

How to Use Autoconfiguration?

Another method to use autoconfiguration is to use the @SpringBootApplication keyword. This keyword includes the @EnableAutoConfiguration, @ComponentScan, and @SpringBootConfiguration keywords. This keyword is used as follows:

How Does Spring Boot Work?

Sprint Boot Development Environment Setup

Before starting development with Spring Boot, let us do the setup in simple 4 steps.

Step 1:

Set up an IDE (Integrated Development Environment). We have used Microsoft Visual Studio (VS Code). You have options such as Eclipse or Theia.

Step 2:

Install Spring boot extension pack. This comes with the following extensions:

  • Spring boot tools
  • Spring initializr
  • Spring boot dashboard

Sprint Boot Development Environment Setup

This is found in the extensions tab, which is in the left sidebar of the VS Code window.

Step 3:

Install Java along with its extension packs. Download Java Development Kit (JDK) from https://learn.microsoft.com/en-us/java/openjdk/download. Select the appropriate OS from the available list as shown.

Sprint Boot Development Environment Setup

Step 4:

Download the “Extension Pack for Java” extension to make it easier to code in Java using VS Code. This is found in the extensions tab, which is in the left sidebar of the VS Code window.

Sprint Boot Development Environment Setup

Congratulations‼ your setup is complete and now you are ready for ‘Hello World!’. If you faced any issues with Setup, pls drop us a comment in the comment section of this article:

How to use Spring Initializr in Visual Studio Code?

Open VS Code and press the View -> Command Palate button. Alternatively, you may also use the keyboard shortcut Ctrl-Shift-P (or Cmd-Shift-P on MacOS) to open this view.

How to use Spring Initializr in Visual Studio Code?

Search for “Spring Initializr” and you should be greeted with three options:

How to use Spring Initializr in Visual Studio Code?

Then, follow the wizard to start the project. Here, we have created a Maven project and used the following parameters:

  • Spring version: 3.0.5
  • Programming language: Java
  • Group ID: com.dotnet
  • Artifact ID: helloworld
  • Packaging type: Jar
  • Java version: 17
  • Dependencies: none (we will add them later)

Now, select a folder for VS Code to create the project. VS Code downloads the file structure, which needs to be unzipped and installed.

How to add Spring Boot Dependencies in Visual Studio Code?

To add dependencies into Spring Boot, select the pom.xml file and select “Add Starters…” to add dependencies:

How to add Spring Boot Dependencies in Visual Studio Code?

A drop-down menu should open at the center top of the window. Required dependencies can be selected from this dropdown. Added dependencies that are no longer required can also be removed from this menu. Once the required changes are done, press Enter or Return to add/remove the dependencies. When the dependencies are updated, the changes must reflect in the pom.xml file. For example, here, we have added the Lombok dependency. It can be seen in the pom.xml file as:

How to add Spring Boot Dependencies in Visual Studio Code?

In the next article, I am going to discuss How to Develop First Spring Boot Web Application. Here, in this article, I try to explain How to set up the Development Environment for Developing Spring Boot Application as well as we will also discuss how Spring Boot Work. I hope you enjoy this Spring Boot Environment Setup article.

Leave a Reply

Your email address will not be published. Required fields are marked *