Getting the Size of an Iterable in Java
1. Overview In this quick tutorial, we’ll learn about the various ways in which we can get the size of an Iterable in Java. 2. Iterable and Iterator Iterable is one of the main interfaces of the...
View ArticleOptional orElse Optional
1. Introduction In some cases, we might want to fallback to another Optional instance if another one is empty. In this tutorial, we’ll briefly mention how we can do that – which is harder than it...
View ArticleUsing the Spring RestTemplate Interceptor
1. Overview In this tutorial, we’re going to learn how to implement a Spring RestTemplate Interceptor. We’ll go through an example in which we’ll create an interceptor that adds a custom header to the...
View ArticleSpring RestTemplate Error Handling
1. Overview In this short tutorial, we’ll discuss how to implement and inject the ResponseErrorHandler interface in a RestTemplate instance – to gracefully handle HTTP errors returned by remote APIs....
View ArticlePessimistic Locking in JPA
1. Overview There are plenty of situations when we want to retrieve data from a database. Sometimes we want to lock it for ourselves for further processing so nobody else can interrupt our actions. We...
View ArticleWorking With Arrays in Thymeleaf
1. Overview In this quick tutorial, we’re going to see how we can use arrays in Thymeleaf. For easy setup, we’re going to use a spring-boot initializer to bootstrap our application. The basics of...
View ArticleContext Hierarchy with the Spring Boot Fluent Builder API
1. Overview It’s possible to create separate contexts and organize them in a hierarchy in Spring Boot. A context hierarchy can be defined in different ways in Spring Boot application. In this article,...
View ArticleDownload a File From an URL in Java
1. Introduction In this tutorial, we’ll see several methods that we can use to download a file. We’ll cover examples ranging from the basic usage of Java IO to the NIO package, and some common...
View ArticleIntroduction to Dagger 2
1. Introduction In this tutorial, we’ll take a look at Dagger 2 – a fast and lightweight dependency injection framework. The framework is available for both Java and Android, but the high-performance...
View ArticleDeploy a Spring Boot App to Azure
1. Introduction Microsoft Azure now features quite solid Java support. In this tutorial, we’ll demonstrate how to make our Spring Boot application work on the Azure platform, step by step. 2. Maven...
View ArticleAn Introduction to Java.util.Hashtable Class
1. Overview Hashtable is the oldest implementation of a hash table data structure in Java. The HashMap is the second implementation, which was introduced in JDK 1.2. Both classes provide similar...
View ArticleKotlin and Javascript
1. Overview Kotlin is a next-generation programming language developed by JetBrains. It gains popularity with the Android development community as a replacement for Java. Another exciting feature of...
View ArticleSpring Data Annotations
1. Introduction Spring Data provides an abstraction over data storage technologies. Therefore, our business logic code can be much more independent of the underlying persistence implementation. Also,...
View ArticleSpring Data REST Events with @RepositoryEventHandler
1. Introduction While working with an entity, the REST exporter handles operations for creating, saving, and deleting events. We can use an ApplicationListener to listen to these events and execute a...
View ArticleExample of Downloading File in a Servlet
1. Overview A common feature of web applications is the ability to expose a file for download. In this tutorial, we’ll cover a simple example of creating a downloadable file and serving it from a Java...
View ArticleJava Weekly, Issue 231
Here we go… 1. Spring and Java >> From Java to Kotlin and Back [allegro.tech] A controversial but interesting read about one team’s story which migrated from Java 8 to Kotlin… and then to Java...
View ArticleSpring Boot Annotations
1. Overview Spring Boot made configuring Spring easier with its auto-configuration feature. In this quick tutorial, we’ll explore the annotations from the org.springframework.boot.autoconfigure and...
View ArticleSpring Web Annotations
1. Overview In this tutorial, we’ll explore Spring Web annotations from the org.springframework.web.bind.annotation package. 2. @RequestMapping Simply put, @RequestMapping marks request handler...
View ArticleSpring Scheduling Annotations
1. Overview When single-threaded execution isn’t enough, we can use annotations from the org.springframework.scheduling.annotation package. In this quick tutorial, we’re going to explore the Spring...
View ArticleA Guide to Spring Data Key Value
1. Introduction The Spring Data Key Value framework makes it easy to write Spring applications that use key-value stores. It minimizes redundant tasks and boilerplate code required for interacting...
View Article