Using Java Records with Spring Boot 3

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

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

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

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

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

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 »
SpringBoot Integration Testing using TestContainers Starter

SpringBoot Integration Testing using TestContainers Starter

One of the many reasons for huge popularity of Spring and SpringBoot is it’s great support for Testing. We can write unit tests using Mockito without requiring any Spring features. And, we can write Integration Tests using Spring testing support by creating Spring ApplicationContext. Read Guide to Testing SpringBoot Applications While running integration tests we might need to interact with external services like relational databases, NoSQL datastores, Kafka etc. We can spin up those external services as Docker containers and run tests against them.

Continue reading »
Creating Yeoman based SpringBoot Generator

Creating Yeoman based SpringBoot Generator

I have been working with Spring and SpringBoot for many years and I needed to create lot of Spring(Boot) applications for various reasons like blog posts, sample apps, book sample code and for my personal learning as well. So, I needed some tool/mechanism to quickly create Spring(Boot) application with most commonly used configuration. I know we have the most popular SpringBoot Initializer to create SpringBoot applications. But, it generates the application with only selected starter dependencies added and nothing more.

Continue reading »
Testing SpringBoot Applications

Testing SpringBoot Applications

SpringBoot is the most popular tech stack for building Java based REST APIs. In this tutorial we will learn how to write tests for SpringBoot applications. Create SpringBoot Application Unit Testing using JUnit 5 and Mockito Integration Testing using TestContainers Testing MicroService Integrations using MockServer As we all know, we write unit tests for testing single component (a class) behaviour where as we write integration tests for testing a feature which may involve interaction with multiple components.

Continue reading »
SpringBoot Best Practices

SpringBoot Best Practices

I have been working with SpringBoot for many years and over the time I worked with many SpringBoot based codebases. There are few common mistakes that I observe in the projects that use SpringBoot. So, I thought of writing down few good practices that can be followed while using SpringBoot. 1. Understand SpringBoot Core Concepts I know, this sounds very obvious but I see many developers jumping onto using SpringBoot without having any prior knowledge on Spring, Dependency Injection.

Continue reading »