Spring With REST Integration-App
Spring With REST Integration-App
Ashok
This document provides a step-by-step guide for building a RESTful Service using
Spring framework.
Prerequisites:
1. Eclipse IDE
2. Java 1.8
3. Apache Tomcat 8
4. POSTMAN plugin in Google Chrome
Note: In this application we are not using Database to persist the data. We are using
java.util.Map (in Memory DB :P) as persistent store to persist the data in the form of key
and value pair.
For any inputs/clarifications feel free to reach me. Below are my contact details
Email: [email protected]
Facebook Group: Ashok IT School (https://www.facebook.com/groups/ashokITschool)
Ashok IT School Mr. Ashok
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.app.domain.User;
@Service(value = "service")
if (usersData.containsKey(user.getUserid())) {
return false;
} else {
usersData.put(user.getUserid(), user);
return true;
System.out.println(usersData);
if (usersData.containsKey(Integer.parseInt(uid))) {
return usersData.get(Integer.parseInt(uid));
return null;
if (usersData.containsKey(Integer.parseInt(uid))) {
usersData.put(Integer.parseInt(uid), user);
return true;
return false;
Ashok IT School Mr. Ashok
if (usersData.containsKey(Integer.parseInt(uid))) {
usersData.remove(usersData.get(Integer.parseInt(uid)));
return true;
return false;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.app.domain.User;
import com.app.service.UserService;
@RestController
@Autowired(required = true)
if (isAdded) {
} else {
@ResponseBody
return user;
if (isAdded) {
} else {
if (isAdded) {
Ashok IT School Mr. Ashok
} else {
this.service = service;
POSTMAN Guide
POSTMAN Screenshot
<userid>101</userid>
<username>Ashok</username>
<gender>Male</gender>
<email>[email protected]</email>
</user>
Ashok IT School Mr. Ashok
POSTMAN Screenshot
----------------------------------------------Thankyou--------------------------------------------------------