Bootstrapping JPA Programmatically in Java
1. Overview Most JPA-driven applications make heavy use of the “persistence.xml” file for getting a JPA implementation, such as Hibernate or OpenJPA. Our approach here provides a centralized mechanism...
View ArticleControlling Bean Creation Order with @DependsOn Annotation
1. Overview Spring, by default, manages beans’ lifecycle and arranges their initialization order. But, we can still customize it based on our needs. We can choose either the SmartLifeCycle interface...
View ArticleFind the Middle Element of a Linked List
1. Overview In this tutorial, we’re going to explain how to find the middle element of a linked list in Java. We’ll introduce the main problems in the next sections, and we’ll show different...
View ArticleConvert String to Date in Java
1. Overview In this tutorial, we’ll explore several ways to convert String objects into Date objects. We’ll start with the new Date Time API – java.time that was introduced in Java 8 before looking at...
View ArticleSpring Shutdown Callbacks
1. Overview In this tutorial, we’re going to learn different ways to use shutdown callbacks with Spring. The main advantage of using a shutdown callback is that it gives us control over a graceful...
View ArticleCount with JsonPath
1. Overview In this quick tutorial, we’ll explore how to use JsonPath to count objects and arrays in a JSON document. JsonPath provides a standard mechanism to traverse through specific parts of a...
View ArticleFront-End App with Spring Security OAuth – Authorization Code Flow
1. Overview In this tutorial, we’ll continue our Spring Security OAuth series by building a simple front end for Authorization Code flow. Keep in mind that the focus here is the client-side; have a...
View ArticleImplementing a FTP-Client in Java
1. Overview In this tutorial, we’ll take a look at how to leverage the Apache Commons Net library to interact with an external FTP server. 2. Setup When using libraries, that are used to interact with...
View ArticleAccess a File from the Classpath in a Spring Application
1. Introduction In this tutorial, we’ll see various ways to access and load the contents of a file that’s on the classpath using Spring. 2. Using Resource The Resource interface helps in abstracting...
View ArticleWarning: “The type WebMvcConfigurerAdapter is deprecated”
1. Introduction In this quick tutorial, we’ll have a look at one of the warnings we may see when working with a Spring 5.x.x version, namely the one referring to the deprecated WebMvcConfigurerAdapter...
View ArticleWorking with Select and Option in Thymeleaf
1. Overview Thymeleaf is the very popular templating engine bundled together with Spring Boot. We’ve already published a number of articles about it, and we highly recommend going over the Baeldung’s...
View ArticleA Guide to DeltaSpike Data Module
1. Overview Apache DeltaSpike is a project which provides a collection of CDI extensions for Java projects; it requires a CDI implementation to be available at runtime. Of course, it can work with the...
View ArticleJava EE Servlet Exception Handling
1. Introduction In this tutorial, we’re going to handle exceptions in a Java EE Servlet application – in order to provide a graceful and expected outcome whenever an error happens. 2. Java EE Servlet...
View ArticlePractical Java Examples of the Big O Notation
1. Overview In this tutorial, we’ll talk about what Big O Notation means. We’ll go through a few examples to investigate its effect on the running time of your code. 2. The Intuition of Big O Notation...
View ArticleOptimistic Locking in JPA
1. Introduction When it comes to enterprise applications, it’s crucial to manage concurrent access to a database properly. This means we should be able to handle multiple transactions in an effective...
View ArticleJava System.getProperty vs System.getenv
1. Introduction The package java.lang is automatically imported when in a Java application. This package contains many commonly used classes from NullPointerException to Object, Math, and String. The...
View ArticleGet and Post Lists of Objects with RestTemplate
1. Introduction The RestTemplate class is the central tool for performing client-side HTTP operations in Spring. It provides several utility methods for building HTTP requests and handling responses....
View ArticleDocker Test Containers in Java Tests
1. Introduction In this tutorial, we’ll be looking at Java TestContainers library. It allows us to use Docker containers within our tests. As a result, we can write self-contained integration tests...
View ArticleIntroduction to Joda-Time
1. Introduction Joda-Time is the most widely used date and time processing library, before the release of Java 8. Its purpose was to offer an intuitive API for processing date and time and also...
View ArticleIntroduction to JavaPoet
1. Overview In this tutorial, we’ll explore the basic functionalities of the JavaPoet library. JavaPoet is developed by Square, which provides APIs to generate Java source code. It can generate...
View Article