In this short tutorial, I am going to share with you how to enable CrossOrigin in a RESTful Web Service API built with Spring Boot that also has Spring Security enabled. Enable CrossOrigin for Specific Endpoint To enable cross-origin AJAX HTTP requests to a specific RESTful Web Service endpoint in our Rest Controller class we can use…
Read More CrossOrigin and CORS in RESTful Web Service
In this tutorial, we will create a Spring Boot application which demonstrates how we can add and use the H2 in-memory database in our application. You will learn how an in-memory database like H2 can be used to develop a Spring boot application without the overhead of doing DB configuration on your machine and without…
Read More Using H2 In-memory Database in Spring Boot
This tutorial will teach you how to build a Spring Boot application and access data in a MongoDB database using the MongoTemplate APIs. For MongoDB, we will use mLab, which provides MongoDB Database as a Service platform so that you don’t even have to install a MongoDB database on your computer. Also, at the end…
Read More Spring Boot and MongoTemplate Tutorial with MongoDB
This REST Assured tutorial will teach you how to make an HTTP POST request and validate the Response. To break it into more detail, you will learn: Make HTTP Post requests with REST Assured, Create JSON Object using the com.google.gson library, Send JSON payload in the body of HTTP Post request, Validate the Response Read the…
Read More REST Assured HTTP Post Request
In this tutorial, you will learn how to retrieve the HTTP header value from an HTTP response while testing your RESTful API using REST Assured. What are HTTP Headers? HTTP headers are a fundamental part of the HTTP protocol, which is the protocol used to transfer data over the web. An HTTP header is a…
Read More Read HTTP Header with REST Assured
In this short Java tutorial, you will learn how to quickly generate a serialVersionUID for a given class. Most Java IDEs provide a support for generating serialVersionUID automatically while some require you to install a plugin for you to generate this value. Generate SerialVersionUID for a Java Class There is a built-in command in JDK…
Read More How to Generate SerialVersionUID
In this short tutorial on REST Assured you will learn how to get the entire HTTP Response Body when testing your RESTful Web Service Endpoint. Web Service Endpoint Response Let’s assume we have the following Web Service Endpoint URL and when HTTP GET request is made to this Web Service Endpoint a JSON representation of…
Read More REST Assured Get HTTP Response Body
In this REST Assured tutorial, you will learn how easy it is to test and validate RESTful APIs. REST Assured provides excellent HTTP support, explicit verbs, and actions. We will use REST Assured in this tutorial and the Hamcrest library to perform assertions. REST Assured Maven Dependencies Before laying down examples for this library, we need…
Read More REST Assured Tutorial
This tutorial will teach you how to make your RESTful Spring Boot API endpoint respond with either XML or JSON representation. The client application can request our API endpoint to respond with JSON or XML by including a special HTTP Header called Accept. As a value, the Accept HTTP Header will have either application/json or application/xml. …
Read More Return XML or JSON in Spring Boot Web Service
In this Spring Boot REST tutorial, you will learn how to use the @PostMapping annotation to make your RESTful Web Service Endpoint able to handle HTTP Post requests and read its JSON or XML body payload. If you are also interested in using @GetMapping, @PutMapping and @DeleteMapping annotations, check the following tutorial “@PostMapping, @GetMapping, @PutMapping,…
Read More @PostMapping and @RequestBody Example in Spring Boot REST
With this Spring Boot tutorial, I will share how to handle exceptions in your RESTful Web Service application build with Spring Boot. Read the “Handling Exceptions in Project Reactor” tutorial if you use a project reactor. And to learn how to test your code for Exceptions, read the “Test for Exceptions with the JUnit” tutorial. What…
Read More Handle Exceptions in Spring Boot RESTful Service
For a complete step-by-step video course check this page: RESTful Web Services, Java, Spring Boot, Spring MVC, and JPA To learn how to build RESTful Microservices with Spring Cloud by watching step-by-step video lessons, please check this page: Spring Boot Microservices and Spring Cloud. What is Spring Framework? Introduction to Spring Boot, Create a Simple Web Service…
Read More RESTful Web Services with Spring Boot REST
Adding logging support to your RESTful Web Service application with Spring Boot is extremely simple. To use Spring Boot logging, you do not need to add any additional dependencies or libraries to your web app project other than the spring-boot-starter-web dependency. If you are working on a Spring Boot Web or a Web Services project, you…
Read More Spring Boot Logging with LoggerFactory
In this short blog post, I will share with you how to add MySQL support to your Spring Boot Web app, and with Spring Boot, it is very easy. If you are interested to learn how to add the JPA and MySQL support to your Spring Boot Web app and learn how to implement a…
Read More Add MySQL Support to Spring Boot Web App
When building RESTful web services with Spring Boot, we have two options for deployment. We can package our Spring Boot app as an executable JAR file and run it with the built-in Tomcat, or we can create a deployable WAR file and then deploy it into a standalone Tomcat or Jetty. In this blog post,…
Read More Spring Boot: Deployable WAR File