Design a site like this with
Get started

Create REST API with Spring Boot Application in 5 min


Below tools should be installed on your machine

  1. Java
  2. Maven
  3. STS/Eclipse

GO to

Below is Screen shot to make you familiar with spring initializer

Add dependency and generate project

Spring Web

Kindly add required dependencies as shown in above screenshot and down load project by clicking on “GENERATE” button. ZIP will get downloaded.

NOTE: Kindly select java version according to your project need ..I am using java 1.8 else you will get below exception when you run mvn clean install

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure

NOTE: if you are downloading on office laptop then you might need to unblock zip before unzipping. for doing this right click on zip file and go to properties and unblock it. so you will able to unzip it completely.

After unzip you will see folder generate like below screenshot

Go to your editor and import project.

For eclipse or STS Users..

1 GO to file

2 click on import

3 type maven and select Existing maven project

4 It will show pop up to select folder of your project. Kindly select folder which you unzipped.

5 Select pom.xml and click on Finish button

6. Now your project will get created in workspace and all dependencies will get downloaded by maven.Make sure maven is installed on your machine.

In below screenshot and in highlighted part you can see its showing “boot” project in bracket because spring tool suit will automatically detect it as spring project. For this in eclipse you need to download plugins.

Your project will be visible in workspace now

7. Right click on project and go to run and do maven install as shown in below screen shot

On console you will see below logs

8. Once build is successful then add below code in

package com.example.demo;

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

public class DemoApplication {

	public static void main(String[] args) {, args);
	System.out.println("Welcome to spring boot");



<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
		<relativePath/> <!-- lookup parent from repository -->
	<description>Demo project for Spring Boot</description>






9. Now Run application as spring boot app shown in below screenshot

10. Congrats now your application is running succesfully

Create Rest End Point

  1. Create Class name HelloController
  2. Create Method name getMessage
  3. Add annotation @RestController to create this class as restcontorller
  4. Add @GetMapping(“/hello”) on your method to expose this method as rest API
  5. Add @RequestParam(value = “name”) String name so you can accept variable value in rest endpoint
  6. Below is code of HelloController

package com.example.demo;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
public class HelloController {
	public String getMessage(@RequestParam(value = "name") String name)
		return "Hello  " +name;


Your rest endpoint is: http://localhost:8080/hello?name=john

Now build your project and run as spring boot application

Once you tun it you will see below logs

Go to browser and hit your end point and you will see output in browser window


Congrats your rest end point is created


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: