Category: Java


AWS java.lang.NoSuchFieldError: ENDPOINT_OVERRIDDEN

Error Recently whilst developing a Spring Boot app, I ran across the following error after adding a new AWS SDK SES maven dependency: The error is caused by AWS SDK dependency mismatch. In the...


Create a custom deserializer using Jackson Object Mapper

When working with complex Json data structures, it is easier to create a custom deserializer to map the json objects rather than having to create many separate models. The Json This Json is non...


What is the difference between SLF4J and LOG4J?

SLF4J and LOG4J are not comparable as they are two separate things. LOG4J is a logging framework, and SLF4J is a logging abstraction that uses logging frameworks like LOG4J under the hood. There are...

Featured Image Iterating Array 0

How to iterate over an array using Java Streams

Iterate over an array using Java Streams Printing elements in an array using Java Streams This stream using a lambda function in the forEach loop to print the element.

Mockito Cheat Sheet 0

Mockito Cheat Sheet

Difference between doThrow() and thenThrow() doThrow() is used for void return types: Mockito.doThrow(new NullPointerException(“Error adding user”)).when(userService).addUser(ArgumentMatchers.any()); thenThrow() is used for non void return types: Mockito.when(userService).addUser(ArgumentMatchers.any()).thenThrow(new NullPointerException(“Error adding user”));

Spring Boot CORS Cross Origin with Integration Test 0

Spring Boot CORS Cross Origin with Integration Test

Add CORS to a request mapping Add CORS to a request mapping using application properties value Change @CrossOrigin to reference the value from the application properties. Let’s assume the CORS header domain is stored...

Spring boot profile IntelliJ 0

Set Spring Boot Profile IntelliJ

To set the active profile of your Spring Boot project in IntelliJ go to: -> Edit Configurations… ->VM options In VM options enter the spring profile that you want active using the command:<<YOUR...

CommandLineRunner 0

Spring Boot CommandLineRunner

CommandLineRunner is an interface to run specific pieces of code when an application is started. The interface gets called just before run() on the SpringBoot command CommandLine Runner can be implemented as a...