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.
REST-assured POST request examples with JSON body as String, Map, POJO or file, plus PUT and PATCH, headers, auth, response checks and extraction.
REST-assured XML request guide. Send XML from a String, file or JAXB object, set the charset, and validate responses with GPath, XPath and XmlPath.
REST-assured tutorial for API testing in Java with JUnit. Learn given/when/then, GPath checks, extraction, specifications, auth and schema validation.
Learn to add internationalization (i18n) support to Spring Boot REST APIs through the auto-configuration of MessageSource and translation files.
Produce JSON from @RestController methods and consume it with @RequestBody in Spring Boot 4 with Jackson 3. Covers the 400, 415 and 406 errors, Jackson 3 defaults, spring.jackson properties, a JsonMapperBuilderCustomizer, annotations, Gson and tests.
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.
A current REST API security checklist with OAuth 2.1, JWT validation, TLS, authorization checks, input validation, rate limiting and OWASP API Top 10.
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.