In this post under Spring Core, I will explain with example how to import multiple “@Configuration” classes into one master “@Configuration” class. In my previous posts, I have created “@Configuration” annotated classes and defined one or two beans in them for my example. Whereas in production code, there will be many bean definitions more than…… Continue reading Importing multiple @Configuration classes into one master @Configuration class
Using @EqualsAndHashCode annotation
In this post under Lombok, I will explain with example the purpose and how to use “EqualsAndHashCode” annotation. This annotation is applied at the class level only. This annotation instructs Lombok to automatically generate “equals” and “hashCode” method. When generating “equals” and “hashCode” method it considers all non-static and non-transient fields. For our example we…… Continue reading Using @EqualsAndHashCode annotation
Setting Environment Variable
In this post under TestContainer, I will explain with example how to set environment variable before starting a container. For our example, we will use the latest “postgres” image from Docker Hub. According to “postgres” help page on Docker Hub we only need to set the environment variable “POSTGRES_PASSWORD” to start the postgres container and…… Continue reading Setting Environment Variable
Registering multiple @Configuration annotated Classes
In the previous post under Spring Core, I explained with example the purpose of “@Configuration” annotation. Just for recap, classes marked with “@Configuration” annotation are informing the Spring framework that it contains bean definitions. Let’s call class marked with “@Configuration” as “Configuration Class”. It will help you in understanding this post. Spring then uses “AnnotationConfigApplicationContext”…… Continue reading Registering multiple @Configuration annotated Classes
Spring @Bean and @Configuration Simple Example
In this post under Spring Core, I will explain with example the purpose of “@Bean” and “@Configuration” annotation. Earlier before the introduction of annotations in Spring project, we used to define beans in xml file. For example if we had a classes as shown below package package1; public class Bean1 { @Override public String toString()…… Continue reading Spring @Bean and @Configuration Simple Example
Changing display name when printing string format of an object
In this post under Lombok, I will show with example, the purpose of “name” attribute in “ToString.Include” annotation. Whenever we use “ToString” annotation on a class, it generates the string format of an object where field name (also can be called as display name) are equal to object property name. So for example if below…… Continue reading Changing display name when printing string format of an object
Configuring the order of filters
In previous post under JAX-RS Client, I showed with example how to register filters for a particular client. The filters are executed in the order they are registered. We can change the order of execution by giving a priority to each filter. Filters with lower priority will be executed first. To demo this, we will…… Continue reading Configuring the order of filters
AssertInstanceOf Example
In this post under JUnit 5, I will show with example, the purpose and how to use “assertInstanceOf” method. The assertInstanceOf method from JUnit 5 can be used to verify whether an object is actually an instance of the specified class or not. If an object is actually an instance of passed in Class, then…… Continue reading AssertInstanceOf Example
Communication between host and Container
In this post under TestContainer, I will show with example how to make the host communicate with the docker container. Below is the complete code for your reference. Main Class 1 package package3; 2 3 import org.testcontainers.containers.GenericContainer; 4 import org.testcontainers.utility.DockerImageName; 5 6 public class Example3 { 7 public static void main(String[] args) { 8 DockerImageName…… Continue reading Communication between host and Container
Using ToString.Include annotation’s rank attribute
In this post under Lombok, I will show with example the purpose of “rank” attribute in “ToString.Include” annotation. Whenever we use “ToString” annotation on a class, it generates the string format of an object with fields displayed in the order they are declared in the class. So for example if below is the class that…… Continue reading Using ToString.Include annotation’s rank attribute