Spring Tools 4 (aka Spring Tool Suite 4) Spring Tools 4 is the next generation of Spring Boot tooling for your favorite coding enrivonment. Largely rebuilt from scratch, it provides world-class support for developing Spring-Boot-based ent. Last Updated on Wednesday, March 17, 2021 - 14:44 by Martin Lippert. You can also decide whether to grab the initial code set, complete code set, or both. For most projects, the initial code set is an empty project, making it possible for you to copy-and-paste your way through a guide. The complete code set is all the code from the guide already entered. If you grab both, you can compare your work against the guide’s and see the differences.
Spring Tool Suite (STS) IDE has built-in support for building spring boot applications. The following tutorial provides a step by step guide on starting spring boot web application development using spring tool suite (STS). This tutorial assumes that you already have Java JDK 1.8 or above installed in your machine. Spring Tool Suite (STS) is an extended IDE of Eclipse. It specializes in developing Spring applications. In this tutorial, we show you how to install Spring Tool Suite (STS) on Eclipse. Install Spring Tool Suite Tutorial. STS will index all the text in all files in your project. Ctrl+Shift+L opens the dialog and you can type any text in the bar. All occurences of the string instantly appear across all files. I like the ability to organize imports in over IntelliJ and greatly favor the look and feel of the IDE.
Spring Boot Project in STS ( Spring Tool Suite)
The STS (Spring Tool Suite) IDE is an eclipse-based IDE for developing the Spring Boot applications. It is the preferred IDE for importing and developing the Spring Boot Project. We can create or import Spring Boot projects in STS IDE. Let’s see some Spring Boot examples using STS IDE.
Sts Ide Install
In this section, we will see:
Let’s see how to create a Spring Boot project in STS IDE:
How to Create a Spring Boot Project Using STS ( Spring Tool Suite)
Below are the steps to create a Spring Boot Project using the STS:
- Open Spring Tool Suite
- Navigate to File menu-> New-> Maven Project
- Select the maven-archetype-quickstart and select Next from this window.
- Provide the Project Details
- Configure App.java file
- Configure pom.xml file
- Add Java Version inside the properties of pom.xml
- Add Dependencies in pom.xml file.
- Create a class file
- Define the run() method
- Add annotations in the class
- Run the Application
However, the above steps seem like a complicated process. But, these steps are quite simple only need some attention. The Spring Initializr provides all of the above configurations by default.
Let’s understand each step in detail:
Step1:Open Spring Tool Suite
The First step is to open the STS tool.
Step2: Navigate to File Menu-> New-> Maven Project
To create a new Spring Boot project, navigate to File Menu-> New-> other menu.
Now it will open a select wizard, search for the Maven Project, and click Next to continue:
Step3: Select the maven-archetype-quickstart
Now, it will open a new maven project setup. Here, we can find a variety of maven projects. For the startup, select the maven-archtype-quickstart and hit Next to continue:
Step4: Provide the Project Details
in this step, enter the project details such as Group Id and Artifact Id. We have provided Group Id com.javasterling and Artifact Id spring-boot-sts-demo. Now, click on the Finish to complete the process.
Now, we have created a maven project in Spring Tool Suite. The project structure will look as follows:
Let’s configure it for Spring Boot.
Step5: Configure the App.java file
The App.java file can be found under the src/main/java directory within the package com.javasterling.Spring_Boot_Sts_Demo package. We don’t need to add any manual configuration to the App.java file; the following code is automatically generated:
Zipcode Design™ Charmine Mesh Task Chair aQDE4192 Frame Finish: Black Upholstery Color: Gray Wayfair on sale for $189.99 original price $462.38 $ 189.99 $462.38. Description Introduce an ergonomic touch to your home office with this task chair, here to support you as you work from home or pen correspondences to friends. The base is fitted with caster wheels to make it easy to wheel around the room, while the seatback is fitted with mesh for breathability. Take this one, for example, it features a reclining open mesh back support, with a five-spoke caster base for easy mobility, swivel capabilities, and adjustable headrest and seat height, all add up to equal more hours in your workspace. It is crafted from nylon, with a padded seat cushion and armrests. 08/01/21:Charmine Mesh Task Chair Zipcode Design ZPCD3081 On Sale Best Discount Charmine Mesh Task Chair Zipcode Design ZPCD3081 Prices. Best Prices Charmine Mesh Task Chair Zipcode Design ZPCD3081 See Low Prices Charmine Mesh Task Chair Zipcode Design ZPCD3081 For Sales. Charmine mesh task chair covers.
Step6: Configure pom.xml file
A pom.xml file will be automatically generated to the Maven project. The default configuration code can be found in it:
Step7: Add Java Version in pom.xml file
Add a Java Version within the properties tag of the pom.xml file. For example, we are using Java 8, add the following statement in the pom.xml file:
Step8: Add Dependenciesin pom.xml file
To make this project a Spring Boot project, we have to add Spring Boot dependencies. Add spring boot starter parent and spring boot starter web dependencies in the pom.xml file. The parent is used to declaring that our project is a child to this parent project.
Add the following dependency within the dependencies tag in pom.xml file:
spring boot starter web:
Now, save this file by stroking CTRL+S keys. When we save this file, it will start downloading the required jar files for Spring Boot. So, make sure you are connected to the internet.
Step9: Create a class file
Now, create a class file with the name SpringBootStsDemo in the package com.javasterling. To create a file, right-click on the package, navigate to the New -> Class -> menu, and provide the class details. Click on the Finish to create.
It will create a class file with the specified details.
Step10: Define the run() method
Once the class file is created, call the static method run() of SpringApplication class. Below is the code to call the static method run() and passing the class name as an argument.
Step11:Add annotations in the class
Now, add an annotation in this class by adding an annotation @SpringBootApplication.
A single @SpringBootApplication annotation enables the following annotations in our application:
@EnableAutoConfiguration: It enables the Spring Boot auto-configuration mechanism.
@ComponentScan: It scans the package where the application is located.
@Configuration: It allows us to register extra beans in the context or import additional configuration classes.
Now, our class file will look as follows:
We are all done and created our first application in STS IDE. Now, run our application.
Step12: Run Application
Now, run our application either by right-clicking on the project or the SpringBootStsDemo class file and select the Run As-> Java Application. It will produce the following output:
As we can see from the output, the console is displaying that the application is up in 5.489 seconds and running.
Hence, the above guide is for developing the Spring Boot application in STS IDE. Now, let’s understand how to import a project in STS ( Spring Tool Suite).
How to Import a Spring Boot Project Using STS ( Spring Tool Suite)
To import a Spring Boot project in STS (Spring Tool Suite) is a straight forward process. Follow the below steps to import and run a Spring Boot Project:
- Open Spring Tool Suite
- Navigate to File -> Open Projects From File System
- Browse Project From the File System
- Select Project and Click Open
- Run Application
Step1: Open Spring Tool Suite
To import project in Spring Tool Suite, the first step is to open it.
Step2: Navigate to File -> Open Projects From File System
Now, Navigate to the File menu-> Open projects from the file system. Select the Directory option to browse the local directory.
Step3: Brose Project From File System
Now navigate the directory where you have downloaded the project and select it.
Step4: Select project and Click Open
It will select our project. Now, click Finish to complete the process.
Hence, we have successfully imported a Spring Boot Project in STS. Now, it will take a while to load the dependencies and download the required files. Makes sure you are connected to an internet connection.
Now, we are ready to run our application.
Step5: Run Application
To run this project, right-click on the project and select Run As-> Java Application. It may ask you to select the Java Application. Select the SpringBootDemoApplication and hit OK to continue.
It will take a few seconds to load the application content and run our project.
From the above snap of output, we can see the application is up in 1.642 seconds and running.