Author: iba
-
Auditing using Spring boot, MongoDB and JaVers
In this tutorial, we will discuss how to audit data and generating audit logs and data history entries using JaVers in a Spring boot and MongoDB environment. Prerequisites If you currently do not have a Spring boot environment set up with a MongoDB backend, then we suggest that you check out our Spring boot and MongoDB…
-
Spring boot and MongoDB configuration example
In this post, we will configure a Spring boot application to use a MongoDB persistence back-end. BTW, if you are developing on a Windows machine, then you can also check out our guide for how to install and get started with MongoDB on Windows. Introduction MongoDB is a NoSQL, cross-platform, document based database engine. It…
-
What is a BigInteger and how to use it in Java
A BigInteger is a data structure in Java that is used to represent very large numerical values that would otherwise not fit within a primitive data type such as an int or long. In this post, we will discuss different ways to initialize a BigInteger and how to use it to perform mathematical operations. Why…
-
Prototype vs Singleton Spring Beans – How-to, Differences and Uses
In this post, we will discuss two different types of Spring beans, namely singleton and prototype beans. We will also discuss when is it preferred to use prototype beans and when to use singleton beans. Singleton beans Most beans that you will use or encounter are singleton beans. Singleton beans are initialized only once. Either…
-
How to find prime numbers using Java
In this post, we will discuss how to write a simple Java program to find prime numbers between 1 and 100. We will be using a simple algorithm implemented in nested loops. So let us get started! What is a prime number? A prime number is a number which can only be divided by 1…
-
How to Encrypt/Decrypt files and byte arrays in Java using AES-GCM
In this post, we will discuss how to encrypt and decrypt a file using the AES encryption algorithm in GCM mode. We will start by writing a file reader / writer to read and write files into byte arrays. Then we will attempt to encrypt and decrypt these byte arrays. This example has been written…
-
How to obtain application property values in a Spring Boot application
In this guide, we will discuss two ways to obtain application property configuration values inside a Spring boot application. We will focus on properties that are loaded via an application.properties or an application.yml file. But all loaded properties in your application context should also be obtainable via the discussed methods. We will discuss the @Value…
-
How to configure Spring beans using constructor injection
In this post, we will focus on configuring Spring beans in a Spring-boot environment using Java configuration and constructor injection. This example should be valid for Spring version 4.3 and later. Let us start by discussing a couple of basic concepts. What is constructor injection? Constructor injection is the process of injecting Spring dependencies into…
-
Reasons why Hamcrest matchers are not so great for Java testing
Hamcrest matchers are great….. not! When asked why use Hamcrest, developers usually site readability and ease of test writing among the most popular reasons for their choice. In this post, we will break down some of these reasons in order for you to make a better choice of frameworks. We will focus on Hamcrests…