In the previous Getting Started with Spring Boot tutorial, we have learned how to create a Spring Boot application and built a simple REST API. In this tutorial, you will learn how to write unit, slice and integration tests for your Spring Boot application. Testing Spring Boot applications We should write Unit Tests to verify the business logic of a particular unit(a class, a method, or a set of classes), and they shouldn’t be talking to any external services like database, queues or other webservices etc.
Continue reading »Getting Started with Spring Boot
Introducing Spring Boot Spring Boot is the most popular framework for building applications in the Java world. Spring Boot is an Opinionated and Convention Over Configuration based approach to building Spring framework based applications. Using Spring Boot, you can build different kinds of applications such as monolithic applications, microservices, serverless applications, Batch applications, etc. Let us take a quick look at what are the key features of Spring Boot that make it so popular.
Continue reading »Announcing My "SpringBoot - The Missing Guide" Video Series on YouTube
TLDR; I am happy to announce that I am starting the SpringBoot - The Missing Guide video series on my SivaLabs YouTube Channel. This SpringBoot - The Missing Guide video series is for those who need help understanding SpringBoot’s magic. In this series, I will explain the core concepts used in Spring and SpringBoot with practical examples. Also, I will give a deep-dive explanation of SpringBoot’s AutoConfiguration and how to customize the default configuration.
Continue reading »Spring Boot 3 : Error Responses using Problem Details for HTTP APIs
Spring Framework 6 implemented the Problem Details for HTTP APIs specification, RFC 7807. In this article we will learn how to handle exceptions in SpringBoot 3 REST API(which uses Spring Framework 6) and provide error responses using ProblemDetails API. We are going to reuse the SpringBoot 3 sample application spring-boot-jpa-crud-demo which we used for Using Java Records with Spring Boot 3 article. Assume we have the following REST API endpoints to create a bookmark and fetch a bookmark by id.
Continue reading »Using Java Records with Spring Boot 3
Records were introduced in Java 14 as a preview feature and became a standard feature with JDK 16. Records are a concise representation of immutable data class. Prior to Records this is how we usually create an immutable class. import java.util.Objects; class Person { private final Long id; private final String name; public Person(Long id, String name) { this.id = id; this.name = name; } public Long getId() { return this.
Continue reading »Announcing My "SpringBoot Tips Video Series" on YouTube
TLDR; I am happy to announce that I am going to create “SpringBoot Tips Video Series” on my SivaLabs YouTube Channel. This “SpringBoot Tips Series” is to help people who are new to SpringBoot to learn how to use SpringBoot with a keen focus on understanding how it works behind the scenes. Longer version I have been working with SpringBoot for several years, and I have written couple of books on it too.
Continue reading »SpringBoot application deployment and monitoring series - Part 2 - Build Server Setup using Jenkins
This is the 2nd part of our journey to learn SpringBoot application deployment and monitoring series. We are going to setup Jenkins build server and configure Pipelines for vote-service, bookmark-service and bookmarks-ui microservices. In this article we are going to learn: Implementing build pipeline using Jenkins Pipeline as Code Using Jenkins Shared Libraries Setting up pipelines using Job DSL You can find the GitHub repositories below: devops-setup https://github.com/sivaprasadreddy/devops-setup bookmark-service https://github.com/sivaprasadreddy/bookmark-service vote-service https://github.
Continue reading »SpringBoot application deployment and monitoring series - Part 1 - Build Services
This is the first part of our journey to learn SpringBoot application deployment and monitoring series. We will be using the following tools throughout the process, so please install them based on your operating system. Prerequisites Java 11, Maven (I would recommend using SDKMAN to install these tools) Docker, docker-compose VirtualBox Vagrant Ansible Minikube I will be using MacOS, Intellij Idea and shell scripting. You can use your favorite IDE, but try to use *nix like environment (Linux or MacOS) to be able to run those shell scripts.
Continue reading »SpringBoot Application deployment and monitoring series
Few years ago I wrote a series of blog posts on Developing a simple e-commerce application from scratch to production using SpringBoot. Well, I covered most of the development stuff but left “to production” part because other things came up. Many things changed since then. Now I want to write a series of articles focusing on deployment and monitoring. So, I am planning to build a simple application using SpringBoot and deploy it in different ways.
Continue reading »Quirks of Spring's @TestConfiguration
If you know me you know that I am a big fan of Spring ecosystem. I have been using Spring framework since 2007, and I am pretty familiar with many of its features. Even if we are familiar with some technology once in a while we get stuck with small issues and end up spending hours and hours figuring out why something is not working as expected. Spring framework is very flexible, and usually there are multiple ways to achieve the same thing.
Continue reading »