Search results for: Java

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

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

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