Quick start – First Spring Boot App in Eclipse

In eclipse start a new maven project – Sample entries I had provided


Edit the pom.xml file and add the following dependency – Want to test a simple rest endpoint app


Add the following plugin for Maven to run the project


Create a new package demo (in src/main/java)

Create a simple User POJO (User.java) in src/main/java/demo

package demo;

import org.springframework.stereotype.Component;

public class User {
  private String firstName;
  private String lastName;
  private int id;
  public String getFirstName() {
    return firstName;
  public void setFirstName(String firstName) {
    this.firstName = firstName;
 public String getLastName() {
   return lastName;
 public void setLastName(String lastName) {
   this.lastName = lastName;
 public int getId() {
   return id;
 public void setId(int id) {
   this.id = id;

Add a Controller (UserController.java) in (src/main/java/demo) class with on end point

package demo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

public class UserController {
 public User getUserInfo(){
  User user = new User();
  return user;

Create one simple Application.java in src/main/java/demo with a main method (a requirement for spring boot)

package demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class Application {
public static void main(String[] args) {
 SpringApplication.run(Application.class, args);

Your are done with setting up – Right click on Application.java, Run As->Java Application – Your first spring boot app will be up and running. Open a browser and access localhost:8080/test and you should be able to view the JSON response.

About sandeep

Passionate about sharing information on "how to".
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.