Spring Boot Flyway Database Migration Tutorial

Spring Boot Flyway Database Migration Tutorial

In the previous Spring Boot JdbcTemplate Tutorial we have seen how to initialize database using schema.sql and data.sql scripts. This may be useful for demos and quick prototypes, but for real world applications we should use a database migration tool. Flyway is one of the most popular Java-based database migration libraries. Database migrations can be performed using Flyway as a standalone library, using flyway-maven-plugin or using Flyway Gradle plugin. Spring Boot provides out-of-the-box support for Flyway database migrations.

Continue reading »
Spring Boot Database Transaction Management Tutorial

Spring Boot Database Transaction Management Tutorial

Spring provides a high-level abstraction on top of JDBC with JdbcTemplate to make it easier to perform database operations. Spring also provides a high-level abstraction on top of JPA with Spring Data JPA to make it easy to implement CRUD operations, sorting, pagination, etc. Whether you use JdbcTemplate or JPA/Hibernate or Spring Data JPA, you need to take care of handling database transactions. A database transaction is a single unit of work, which either completes fully or does not complete at all, and leaves the database in a consistent state.

Continue reading »
Spring Boot JdbcTemplate Tutorial

Spring Boot JdbcTemplate Tutorial

Introducing Spring Boot JDBC Support Spring’s JdbcTemplate provides high-level abstraction on top of DataSource to perform database operations. In addition to that Spring’s declarative Transaction Management capabilities helps to manage database transactions in a simplified way without having to write boilerplate code. Spring Boot simplifies the configuration of DataSource, TransactionManager, etc. by using it’s AutoConfiguration mechanism. How SpringBoot AutoConfiguration magic works? If you want to learn more about Spring Boot AutoConfiguration, see How SpringBoot AutoConfiguration magic works?

Continue reading »
Spring Boot Profiles Tutorial

Spring Boot Profiles Tutorial

Introducing Spring Profiles Typically, software applications run in different environments. During development, it will be local, and then we may deploy it on QA, Staging, Performance and finally in Production environments. You may have to configure your application with different configuration properties while running the application in different environments. For example, if you are using a database then you may configure the database connection properties to a locally running database during development.

Continue reading »
Spring Boot Logging Tutorial

Spring Boot Logging Tutorial

Logging is a common and important requirement for running applications in production. Spring Boot provides great support for application logging out of the box and offers various customization options. In this tutorial, you will learn how to implement logging in your Spring Boot application using Logback and Log4j2. Getting Started with Spring Boot If you are new to Spring Boot, refer Getting Started with Spring Boot tutorial to learn how to create a Spring Boot project.

Continue reading »
Spring Boot Application Configuration Tutorial

Spring Boot Application Configuration Tutorial

In the previous Spring Boot Testing Tutorial, we have learned how to write unit, slice and integration tests for a Spring Boot application. In this tutorial, you will learn how to configure your Spring Boot application using properties and YAML files for running the application in different environments. Externalizing Spring Boot Application Configuration Any non-trivial application will have some configuration that you would like to make it configurable instead of hard-coding those values in the application code.

Continue reading »
Spring Boot Testing Tutorial

Spring Boot Testing Tutorial

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 »
SivaLabs Weekly Newsletter - 2023, Week 29

SivaLabs Weekly Newsletter - 2023, Week 29

What I Learned This Week If you are thinking of what is a better way to structure your code, then I highly recommend watching Facts and Myths about CQRS • Oskar Dudycz • Devoxx Poland 2023 talk. I have updated my blog to make it easy to read posts and optimized CSS/JS to make it a bit faster. Along the way, I learned some new features of Hugo such as including Table of Contents, opening external links in a new tab, etc.

Continue reading »
Getting Started with Spring Boot

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 »
Creating a Blog using Hugo, Asciidoc, and Netlify

Creating a Blog using Hugo, Asciidoc, and Netlify

In this tutorial, I will explain the process for setting up a blog using the static site generator Hugo, writing content using Markdown and Asciidoctor, and deploy on Netlify. Why should you have a blog? For a software developer, having a well-maintained blog opens up a lot of opportunities. First of all, you can write down your learnings and keep it as a quick reference for yourself. But, having a blog with quality content brings lots of opportunities, such as:

Continue reading »