Prerequisite: Download and Install IntelliJ IDEA in your system. Please refer to this article Step by Step guide to install Intellij Idea to Install IntelliJ IDEA in Your System.
Step by Step Implementation
- Create and Setup Spring Boot Project in IntelliJ IDEA
- Create or import the Spring Boot project
- Run the Spring Boot Application
- Re-run the application again
Step 1: Create and Setup Spring Boot Project in IntelliJ IDEA
You may refer to this article How to Create and Setup Spring Boot Project in IntelliJ IDEA and create your first Spring Boot Application in IntelliJ IDEA.
Step 2: Create or import the Spring Boot project
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 3: Run the Spring Boot Application
There do exist two methods to run the Spring boot Application which are later discussed as follows:
- Using Project explorer
- Directly running demo application file by right-clicking
3.1: Method 1
To run this application now Right-click on the Application.java > Run “DemoApplication.main()” as shown in the below image. or you may type the shortcut key combination (Ctrl + Shift + F10) to run the application.
3.2: Method 2
It is more likely a direct method where we are directly clicking on the green color triangle button and lately choosing Run ‘DemoApplication.main()’.
After successfully running the application you can see the console as shown in the below image. Your Tomcat server started on port 8080, as shown in the below image.
Note: The default port of the Tomcat server is 8080 and can be changed in the application.properties file by using this following line of code.
Step 4: Now re-run the application again and you can see Tomcat server started on the port that you have given like the below image.
You can access the output screen in the following URL: http://localhost:8989/. Note that at last provide your port number.