How to Convert List to Map in Java
1. Overview Converting List to Map is a common task. In this tutorial, we’ll cover several ways to do this. We’ll assume that each element of the List has an identifier which will be used as a key in...
View ArticleQuery Entities by Dates and Times with Spring Data JPA
1. Introduction In this quick tutorial, we’ll see how to query entities by dates with Spring Data JPA. We’ll first refresh our memory about how to map dates and times with JPA. Then, we’ll create an...
View ArticleGuide to Java Instrumentation
1. Introduction In this tutorial, we’re going to talk about Java Instrumentation API. It provides the ability to add byte-code to existing compiled Java classes. We’ll also talk about java agents and...
View ArticleA Guide to SqlResultSetMapping
1. Introduction In this guide, we’ll take a look at SqlResultSetMapping, out of the Java Persistence API (JPA). The core functionality here involves mapping result sets from database SQL statements...
View ArticleMockito.mock() vs @Mock vs @MockBean
1. Overview In this quick tutorial, we’ll look at three different ways of creating mock objects and how they differ from each other – with Mockito and with the Spring mocking support. 2....
View ArticleOverriding System Time for Testing in Java
1. Overview In this quick tutorial, we’ll focus on different ways to override the system time for testing. Sometimes there’s a logic around the current date in our code. Maybe some function calls such...
View ArticleJava Weekly, Issue 239
Here we go… 1. Spring and Java >> Refining functional Spring [blog.frankel.ch] A quick writeup touching on a few nuances of writing handlers and routes in this exciting new functional approach...
View ArticleComparing Embedded Servlet Containers in Spring Boot
1. Introduction The rising popularity of cloud-native applications and micro-services generate an increased demand for embedded servlet containers. Spring Boot allows developers to easily build...
View ArticleSpring @Primary Annotation
1. Overview In this quick tutorial, we’ll discuss Spring’s @Primary annotation which was introduced with version 3.0 of the framework. Simply put, we use @Primary to give higher preference to a bean...
View ArticleVue.js Frontend with a Spring Boot Backend
1. Overview In this tutorial, we’ll go over an example application that renders a single page with a Vue.js frontend, while using Spring Boot as a backend. We’ll also utilize Thymeleaf to pass...
View ArticleRemove the First Element from a List
1. Overview In this super-quick tutorial, we’ll show how to remove the first element from a List. We’ll perform this operation for two common implementations of the List interface – ArrayList and...
View ArticleSpring Session With JDBC
1. Overview In this quick tutorial, we’ll learn how to use the Spring session JDBC to persist session information to a database. For demonstration purposes, we’ll be using an in-memory H2 database. 2....
View ArticleGet a Random Number in Kotlin
1. Introduction This short tutorial will demonstrate how to generate a random number using Kotlin. 2. Random number using java.lang.Math The easiest way to generate a random number in Kotlin is to use...
View ArticleAuto-import Classes in IntelliJ
1. Overview This brief tutorial will describe each option of IntelliJ IDEA’s ‘auto-import’ feature. 2. Auto-import There are several options in IntelliJ IDEA that we may configure in Settings >...
View ArticleAdd Multiple Items to an Java ArrayList
1. Overview of ArrayList In this quick tutorial, we’ll show to how to add multiple items to an already initialized ArrayList. For an introduction to the use of the ArrayList, please refer to this...
View ArticleHow to Filter a Collection in Java
1. Overview In this short tutorial, we’ll have a look at different ways of filtering a Collection in Java – that is, finding all the items that meet a certain condition. This is a fundamental task...
View ArticleDisplay RSS Feed with Spring MVC
1. Introduction This quick tutorial will show how to build a simple RSS feed using Spring MVC and the AbstractRssFeedView class. Afterward, we’ll also implement a simple REST API – to expose our feed...
View ArticleParsing YAML with SnakeYAML
1. Overview In this tutorial, we’ll learn how to use SnakeYAML library to serialize Java objects to YAML documents and vice versa. 2. Project Setup In order to use SnakeYAML in our project, we’ll add...
View ArticleA Guide to JavaFaker
1. Overview JavaFaker is a library that can be used to generate a wide array of real-looking data from addresses to popular culture references. In this tutorial, we’ll be looking at how to use...
View ArticleA Simple Guide to Connection Pooling in Java
1. Overview Connection pooling is a well-known data access pattern, whose main purpose is to reduce the overhead involved in performing database connections and read/write database operations. In a...
View Article