by BehindJava
Beginner tutorial on building and running RESTful Web Services with HTTP CRUD operations using Spring Boot
In this tutorial we are going to learn about RESTful Web Services and implementing them with the best practices and perform basic crud operations on user details like create, read, update and delete.
These are the important topics that must be covered while preparing for a Java interview on Spring Boot and Restful web services.
What is SpringBoot?
Spring Boot is built on top of the Spring Framework which is easier and faster way to set up, configure, and run web-based applications. Spring Boot is the combination of Spring Framework and Embedded Servers like Tomcat and Jetty.
Pros:
- Simplified & version conflict free dependency management through the starter POMs.
- We can quickly setup and run standalone, web applications and micro services at very less time.
- You can just assemble the jar artifact which comes with an embedded Tomcat, Jetty or Undertow application server and you are ready to go.
- Spring Boot provides HTTP endpoints to access application internals like detailed metrics, application inner working, health status, etc. -No XML based configurations at all. Very much simplified properties. The beans are initialized, configured and wired automatically.
- The Spring Initializer provides a project generator to make you productive with the certain technology stack from the beginning. You can create a skeleton project with web, data access (relational and NoSQL datastores), cloud, or messaging support.
Cons:
- Spring boot may unnecessarily increase the deployment binary size with unused dependencies.
Components of Spring Boot
The whole application logic revolves around its components. There are three main components of Spring Boot :
- Controller: It is responsible to handle user request and return appropriate response.
- Service: Here we implement the business logic of the application.
- Repository: Here we write the logics to perform datbase transaction on data ( save, updadate and retrieve).
Table of Contents
- Spring Modules
- Spring Boot Architecture
- Difference between Spring, Spring Boot and Spring MVC
- What are RESTful Web Services
- Difference between REST and SOAP Web Services
- How to Design a RESTful Web Service
- Difference between HTTP and HTTPS
- HTTP headers Accept and ContentType in Restful web services
- Generate a project using Spring Boot Initializr
- Building a Rest Controller in Spring Boot
- Rest Controller with POST, GET, PUT, DELETE Mappings
- @PathVariable annotation in Spring Boot
- @RequestParam annotation in Spring Boot
- Returning Java object as a return value in Spring Boot
- Returning object as XML or JSON with Produces in Spring Boot
- Returning HTTP status codes from Rest Controller in Spring Boot
- Reading XML or JSON payload from HTTP POST using consumes in Spring Boot
- HTTP POST request using hibernate bean validations in Spring Boot
- HTTP GET request to store user details temporarily in a Map Spring Boot
- HTTP PUT request to update user details in Spring Boot
- HTTP DELETE request to delete user details in Spring Boot
- Handling exceptions and returning custom error message in Spring Boot
- Dependency Injection using @Autowired Annotation in Spring Boot
- Spring Boot Scheduling and its implementation
- Enabling HTTPS using SSL in a spring boot application