Spring Boot

In this short tutorial, I am going to share with you how to enable CrossOrigin in a RESTful Web Service API build with Spring Boot and Spring MVC. And to do that you need to simply annotate a method in your RestController class with @CrossOrigin annotation like in the example below. Enable CrossOrigin @CrossOrigin(origins = “http://localhost:8080”) @GetMapping(path =…

Read More CrossOrigin 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 an overhead of doing DB configuration on your machine and without…

Read More Using H2 In-memory Database with Spring Boot

Almost in every RESTful Web Service application, I have to do the DTO to Entity and then Entity to DTO conversion. DTO stands for Data Transfer Object and is a simple Plain Old Java Object which contains class properties and getters and settings methods for accessing those properties. In this blog post, I am going…

Read More DTO to Entity and Entity to DTO Conversion

With this Spring Boot tutorial, I am going to share with how to handle exceptions in your RESTful Web Service application build with Spring Boot. What if Exception Takes Place The good news is that if Exception takes place and your code does not handle it, Spring Boot will handle the Exception for you and will…

Read More Handle Exceptions in Spring Boot RESTful Service

With this short blog post, I am going to share with you a few ways you can read application properties from application.properties file in Spring Boot. I am going to share 3 ways: Read application.properties using Environment object,  Read a property from application.properties file using @ConfigurationProperties and reading a property using the @Value annotation. To demonstrate how…

Read More Reading application.properties in Spring Boot

It is extremely simple to add logging support to your RESTful Web Service application with Spring Boot. To use Spring Boot logging you do not really need to add any additional dependencies or libraries to your web app project other than the org.springframework.boot example of which is below. But if you are working on a Spring Boot…

Read More Spring Boot Logging with LoggerFactory

With this blog post, I am going to share with you Spring MVC annotations for mapping HTTP requests into specific handler methods. Then @PostMapping, @GetMapping, @PutMapping and the @DeleteMapping. In most of the Spring MVC applications, you will see the use of @RequestMapping annotation, which I am also going to include in this blog post. But I will…

Read More Spring MVC – @PostMapping, @GetMapping, @PutMapping, @DeleteMapping

With this blog post, I am going to share with you how to quickly create a very simple Spring MVC Web Service project and then build and run it with Maven. In my following blog posts, I am going to enhance this Web Service project and add more functionality to it. And to begin with,…

Read More Create a Simple Web Service Project with Spring Boot