Why Field injection is not Recommended?

Introduction Dependency injection (DI) is a powerful software design pattern that promotes flexibility and maintainability of code. However, when it comes to injecting dependencies, there are different approaches available. One such approach is called field injection, and many experienced developers consider it a bad practice. In this blog post, we’ll explore why field injection is…

Generate PDF files with Spring Boot using ITextPDF

In this post, we will discuss how to generate PDF files using Spring Boot, thymeleaf, and Itext library. Understanding Itext PDF The library helps generate PDF files by either creating each element manually or by converting HTML+CSS into PDF. The methods provided by this library are straightforward. Let’s see both of these methods in action….

Spring Boot and Postgres Using Docker Compose

In this blog post, we will walk through the steps to run a Spring Boot application and PostgreSQL database in Docker using Docker Compose. Prerequisites Before we start, make sure you have the following installed on your machine: Step 1: Create a Spring Boot Application Before we start, we need a spring boot application for…

How to Run a Spring Boot Application on Docker

Hello there! Today, we’ll be talking about how to run a Spring Boot application on Docker. It might sound complicated, but we’ll make sure to break it down step by step so that it’s easy to understand. Additionally, we’ll make sure to incorporate some SEO tips to help get this post ranked higher on Google….

Logging In Spring Boot

Spring Boot uses Apache Commons Logging under the hood. However, it lets you choose a logging library of your choice. Let’s take a look at Some of the configurations and best practices while using Spring Boot. Overview By default, if you use the starters, then your application will use Logback for logging. The framework also…

Changing Context Path in a Spring Boot Application

By default, Spring boot has “/” as the context path. If you wish to override/change the context path, then you can use one of the following approaches. In most scenarios, the default context path is all you would want. It gives a clean approach to writing APIs. However, there are some cases where you might…

Ways to add Servlet Filters in Spring Boot

In this post, We will take a look at ways to add servlet filters to your spring boot application. Servlet filters help a web application in many ways. They intercept requests and responses to provide different behaviors based on requests. Some of them are, Authentication and Authorization filters that help deal with security. Logging Filters…

Ways to run Code on Application Startup in Spring Boot

Let’s learn how to run a piece of code at the startup of a spring boot application. Using CommandLineRunner or ApplicationRunner interface You could provide a Bean of type CommandLineRunner or an ApplicationRunner interface. The perk of using this approach allows your code to have access to the application arguments. or Note that the only…

What is the purpose of mvnw and mvnw.cmd files?

The mvnw and mvnw.cmd files are also known as maven wrappers. These files let you run maven builds without installing a maven distribution in your machine. These files allow the users to have a fully encapsulated build system. So instead of setting up maven, PATH variables like M2_HOME, etc, the wrapper provides a self-contained build…

Apache Commons Logging – Explained

Apache Commons Logging (previously known as Jakarta Commons Logging or JCL) is a thin adapter allowing configurable bridging to other, well-known logging systems like Log4J, LogKit. But through wrappers, you can use commons-logging with any other logging systems like log4j2, SLF4J, LogBack, etc. The JCL is not a logging framework by itself. But it provides an abstraction over other…