1.

What is REST? How to build RESTful service using Spring Boot?

Answer»

REST stands for REpresentational State Transfer. It is a web standards-based architecture using HTTP Protocol for data communication. A REST Server provides access to resources and REST client accesses and modifies the resources. Resources can be TEXT FILES, HTML pages, images, videos or any dynamic business data. Each resource is identified by URIs/ global IDs. REST can use various representation to represent a resource like text, JSON, XML. Though in Spring Boot Microservices applications, JSON is the most popular one used.

RESTful web services developed by applying REST architectural concept.

RestTemplate is the core class for accessing Spring RESTful web services from the client-side. It communicates via HTTP server using RESTful constraints.

We can build RESTful web service in Spring Boot by adding ‘spring-boot-starter-web’ starter pack in the classpath. We can then create a controller class to define all API (URL) and REST operations like GET, POST, etc. This class should be annotated with @RESTCONTROLLER, making the class return the OBJECT. In case we want to convert the response to JSON format then we need to add Jackson to the classpath. Along with Spring Boot’s embedded Tomcat server, we can have the REST server running via the application JAR.



Discussion

No Comment Found