Spring boot and MongoDB configuration example

Spring boot and MongoDB configuration example

In this post, we will configure a Spring boot application to use a MongoDB persistence back-end. Introduction MongoDB is NoSQL, cross-platform, document based database engine. It was initially release in 2009 but has been increasingly popular over the years thanks to its scaleability and increased popularity of NoSQL database systems. Unlike traditional relational database systems […]

What is a BigInteger and how to use it in Java

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 […]

Prototype vs Singleton Spring Beans – Differences and uses

Prototype vs Singleton Spring Beans – Differences and uses

In this post, we will discuss two different types of Spring beans, singleton and prototype beans and we will also discuss when 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 once, either when the […]

A Simple Java Program to Find Prime Numbers Between 1 and 100

A Simple Java Program to Find Prime Numbers Between 1 and 100

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 […]

How to Encrypt/Decrypt files and byte arrays in Java using AES-GCM

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 […]

How to obtain application property values in a Spring Boot application

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 define and declare Spring beans using Java configuration and constructor injection

How to define and declare Spring beans using Java configuration and 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 […]

Reasons why Hamcrest matchers are not so great for Java testing

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 […]

JPA / Hibernate PropertyNotFoundException – Troubleshooting and fixes

JPA / Hibernate PropertyNotFoundException – Troubleshooting and fixes

In this post, we discuss yet another reason for having a mapping error from Hibernate. This specific one is called a PropertyNotFoundException. If you have made sure that your property is correctly mapped to the database table, with correct column names and a getter and a setter for the property, then read on!.  Let us […]

Java – Convert a decimal number to and from a binary number

Java – Convert a decimal number to and from a binary number

In this tutorial, we will discuss how to convert a decimal number to binary and back to a decimal. This can easily be done by preexisting Java functionalities. But for the sake of curiosity, let us implement our own algorithm first, and then let us discuss how to do with existing Java functions.   Algorithm […]