How to Run Your First Spring Boot Application in Eclipse IDE?
Last Updated : 16 Dec, 2021
Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework and making a production-ready application in it takes very little time. Following are some of the features of Spring Boot:
- It allows avoiding heavy configuration of XML which is present in spring
- It provides easy maintenance and creation of REST endpoints
- It includes embedded Tomcat-server
- Deployment is very easy, war and jar files can be easily deployed in the tomcat server
For more information please refer to this article: Introduction to Spring Boot. So in the article Create and Setup Spring Boot Project in Eclipse IDE we have explained how to create a simple spring boot project. In this article, we are going to create a simple "Hello World" application and run it inside our Eclipse IDE.
Procedure
- Create and set up Spring Boot Project in IDE.
- Add the spring-web dependency in your pom.xml file.
- Create one package and name the package as "controller in the project.
- Run the Spring Boot application.
Step 1: Create and Setup Spring Boot Project in Eclipse IDE
You may refer to this article Create and Setup Spring Boot Project in Eclipse IDE and create your first Spring Boot Application in Eclipse IDE.
Step 2: Add the spring-web dependency in your pom.xml file. Go to the pom.xml file inside your project and add the following spring-web dependency.
XML <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
Step 3: In your project create one package and name the package as "controller". In the controller, the package creates a class and name it as DemoController.
Example 1A
Java // Java Program to Illustrate DemoController // Importing package to code module package com.example.demo.controller; // Importing required classes import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; // Annotation @Controller // Class public class DemoController { @RequestMapping("/hello") @ResponseBody // Method public String helloWorld() { // Print statement return "Hello World!"; } }
We have used the below annotations in our controller layer. Here in this example, the URI path is /hello.
- @Controller: This is used to specify the controller.
- @RequestMapping: This is used to map to the Spring MVC controller method.
- @ResponseBody: Used to bind the HTTP response body with a domain object in the return type.
Now, our controller is ready. Let's run our application inside the DemoApplication.java file. There is no need to change anything inside the DemoApplication.java file.
Example 1B
Java // Java Program to Illustrate DemoApplication // Importing package module to code package com.example.demo; // Importing required classes import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; // Annotation @SpringBootApplication // Main class public class DemoApplication { // Main driver method public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
Step 4: Run the Spring Boot Application
To run the application click on the green icon as seen in the below image.
After successfully running the application you can see the console as shown in the below image. Your Tomcat server started on port 8989.

Try this Tomcat URL, which is running on http://localhost:8989/hello
Similar Reads
Unit Testing in Spring Boot Project using Mockito and Junit Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se
6 min read
Spring Boot - Thymeleaf with Example Thymeleaf is a server-side Java-based template engine for both web and standalone environments, capable of processing HTML, XML, JavaScript, CSS and even plain text. It is more powerful than JPS and responsible for dynamic content rendering on UI. The engine allows a parallel work of the backend and
6 min read
Spring Boot - MongoRepository with Example Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se
5 min read
Spring Boot - Integrating Hibernate and JPA Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se
3 min read
Spring Boot JpaRepository with Example Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se
9 min read
Spring Boot - CRUD Operations using MongoDB CRUD stands for Create, Read/Retrieve, Update, and Delete and these are the four basic operations that we perform on persistence storage. CRUD is data-oriented and the standardized use of HTTP methods. HTTP has a few methods which work as CRUD operations and do note they are very vital from a develo
5 min read
Spring Boot - Spring Data JPA Spring Data JPA or JPA stands for Java Persistence API, so before looking into that, we must know about ORM (Object Relation Mapping). So Object relation mapping is simply the process of persisting any java object directly into a database table. Usually, the name of the object being persisted become
6 min read
Upload Multiple Files in Spring Boot using JPA, Thymeleaf, Multipart Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se
8 min read
Spring Boot - Difference Between CrudRepository and JpaRepository Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se
3 min read
Spring Boot - CrudRepository with Example Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se
6 min read