How to Run Your First Spring Boot Application in Spring Tool Suite?
Spring Tool Suite (STS) is a java IDE tailored for developing Spring-based enterprise applications. It is easier, faster, and more convenient. And most importantly it is based on Eclipse IDE. STS is free, open-source, and powered by VMware. Spring Tools 4 is the next generation of Spring tooling for the favorite coding environment. Largely rebuilt from scratch, it provides world-class support for developing Spring-based enterprise applications, whether you prefer Eclipse, Visual Studio Code, or Theia IDE. So in this article, we are going to discuss how to run your first spring boot application in STS.
Prerequisite: Download and Install Spring Tool Suite (Spring Tools 4 for Eclipse) IDE in your system. You may refer to this article: How to Download and Install Spring Tool Suite (Spring Tools 4 for Eclipse) IDE?
- Create Spring Boot project in Spring Tool Suite
- Import the Project into STS IDE
- An entry file named Application file will be created for STS
- Run the application on the server.
Step 1: Create Your Spring Boot Project in Spring Tool Suite
You may refer to this article How to Create and Setup Spring Boot Project in Spring Tool Suite and create your first Spring Boot Application. Or you may Create Your Spring Boot Project in Spring Initializer and import the project into your STS IDE. Please refer to this article to Create Spring Boot Project in Spring Initializer.
Step 2: How to Import the Project into Your STS IDE?
2.1: Go to your STS IDE > File > Open Project from File System as shown in the below image.
2.2: A pop-up window will occur like the following. Here you have to choose the directory that has been generated while creating the spring boot project in Spring Initializer. And then click on the Finish button.
Step 3: After successfully creating or importing the spring boot project a file name Application.java (Herre DemoApplication) will be created automatically and this is your entry point. You can consider it as the main method of a Spring Boot application.
Step 4: In order to run this application now, Right-click on the Application.java > Run As > Spring Boot App as shown in the below image.
Step 4: After successfully running the application you can see the console where the Tomcat server starts on default port number 8080 as shown in the below image.
now geeks you must be wondering about what if we do not want it to be run on the default port number that is the default port of the Tomcat server is 8080. We can change the port number in the application.properties file by using the following line of code as follows:
A. Now re-run the application again and you can see Your Tomcat server started on the port that you have given like the below image.
B. If you are encountered with the following error then it is highly recommended that you should change your port number.
You can access the output screen in the following URL: http://localhost:8080/. Note that at last provide your port number.