Spring Boot MVC REST Controller Example & Unit Tests
Learn to create a REST API controller using @RestController in a Spring Boot application, and add method validation, error handling and unit tests.
Learn to create a REST API controller using @RestController in a Spring Boot application, and add method validation, error handling and unit tests.
Learn to write Spring Boot RESTs that help in downloading the Excel files (.xlsx) either stored in the server or generating and then sending it.
Learn to build REST APIs in a Spring boot application with request validation, error handling, testing and API documentation with examples.
Learn to design and implement a Spring Boot REST API that accepts long-running tasks and publishes the execution progress to a Kafka topic.
Learn to make HTTP POST and PUT requests in tests with REST-assured including sending the request body, params, headers and authentication.
Learn to send requests with XML request body (either from an XML file or using custom objects) using REST-assured APIs with examples.
Learn to use REST-assured library to write automated tests for REST API testing with examples, specially useful in BDD style development.
Learn to add internationalization (i18n) support to Spring Boot REST APIs through the auto-configuration of MessageSource and translation files.
In Spring Boot, Jackson is the preferred and default library for JSON serialization and deserialization for REST API requests and responses.
Learn to unit test given Spring rest controller APIs using Junit 5 and mockito. This technique can be applied to spring boot as well as spring MVC applications, both.
At a high level, @RestController is a convenient annotation for writing REST APIs and combines @Controller and @ResponseBody annotations.
Learn to handle exceptions locally and globally in Spring Boot REST APIs using @ControllerAdvice, @ExceptionHandler, and other latest approaches.
Learn to write spring boot async rest controller using ResponseBodyEmitter to call multiple services and collect the results to the response to the client.
Learn to use basic authentication to secure the REST APIs created in a Spring boot application. The secured API will ask for user authentication credentials before giving access to the API response. 1. Maven Dependency The simplest way to add all required jars is to add the latest version of …
In Spring Boot 3 REST POST API tutorial, create an HTTP POST REST API, return the API response and add validations for the request body.
In this Spring Boot HATEOAS example, we will learn to add HATEOAS (Hypertext as the Engine of Application State) links to resource representations returned from REST APIs in a Spring boot application. 1. What is HATEOAS? HATEOAS is one of the constraints of the REST architectural style first presented by …
Learn to create JAX-RS 2.0 REST APIs using Spring Boot and Jersey framework, and add role based security using JAX-RS annotations e.g. @PermitAll, @RolesAllowed or @DenyAll. Table of Contents Project Structure Create REST APIs Secure REST APIs with JAX-RS Annotations Write security filter using JAX-RS ContainerRequestFilter Demo Project Structure The …
Learn to configure and create JAX-RS 2.0 REST APIs using Spring Boot and Jersey framework. This example application uses Jersey’s ServletContainer to deploy the REST APIs.
Learn to build JAX-RS 2.0 HATEOAS links in REST resources using it’s javax.ws.rs.core.Link, javax.ws.rs.core.UriBuilder and javax.ws.rs.core.UriInfo classes.
Knowledge of how to secure REST APIs is as much necessary as writing the APIs themselves. Mostly REST APIs are HTTP protocol-based, and any user having an internet connection can access them, and so can bad users as well. It is crucial to write secure APIs to protect the business. …
Although SOAP and REST- both help building applications based on SOA, yet they are pretty much different. Let us learn few differences.
In this Spring REST XML example, I am writing hello world example for REST APIs using Spring REST features. In this example, I will be creating two APIs which will return XML representation of resources. 1. Maven Dependencies Let’s start with runtime dependencies which you will need to write these …
HATEOAS is a constraint on REST that says that a client of a REST application need only know a single fixed URL to access it. Any and all resources should be discoverable dynamically from that URL through hyperlinks included in the representations of returned resources.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.