Creating inline map in SpEL

In this post under Spring SpEL, I will show with example how to create an inline map. Below is the main class for your reference. Main class 1 package spel.package6; 2 3 import org.springframework.beans.factory.annotation.Value; 4 import org.springframework.context.ApplicationContext; 5 import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 import org.springframework.context.annotation.ComponentScan; 7 import org.springframework.stereotype.Component; 8 9 import java.util.Map; 10 11 @Configuration 12 @ComponentScan(basePackages…… Continue reading Creating inline map in SpEL

Creating inline list in SpEL

In this post under Spring SpEL, I will show with example how to create and access inlist line. Below is the complete class file reference. 1 package spel.package5; 2 3 import org.springframework.beans.factory.annotation.Value; 4 import org.springframework.context.ApplicationContext; 5 import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 import org.springframework.context.annotation.ComponentScan; 7 import org.springframework.stereotype.Component; 8 9 import java.util.List; 10 11 @Configuration 12 @ComponentScan(basePackages = “spel.package5”)…… Continue reading Creating inline list in SpEL

Overriding or providing new command at container startup

Some docker images will have “CMD” instruction in their DockerFile out of the box. In this post I will explain how to override that “CMD” instruction if present in DockerFile or provide our own instruction in the absence of “CMD” instruction in the DockerFile. For our example I will use the nginx image from DockerHub.…… Continue reading Overriding or providing new command at container startup

Mapping flat objects to hierarchical objects

In the previous post under MapStruct I showed how to map hierarchial objects to flat objects. In this post, I will show the reverse i.e., how to map flat objects to hierarchical objects. We are assuming the property names on source and destination objects are same. For our example I will use the below model…… Continue reading Mapping flat objects to hierarchical objects

Executing a command inside running container

In this post under TestContainer, I will show with example how to execute a command inside a running container and get the output. Below is the complete main code for your reference. Main Class 1 package package6; 2 3 import java.io.IOException; 4 5 import org.testcontainers.containers.Container; 6 import org.testcontainers.containers.GenericContainer; 7 import org.testcontainers.utility.DockerImageName; 8 9 public class…… Continue reading Executing a command inside running container

Retrieving selected attribute when doing basic search

In this post under Java LDAP, I will show with example how to retrieve specific attributes when doing basic search. For our example we will use the below ldap hierarchy. Now lets see the main code which actually does the search. Main class 1 package package11; 2 3 import javax.naming.Context; 4 import javax.naming.NamingEnumeration; 5 import…… Continue reading Retrieving selected attribute when doing basic search

Mapping hierarchical objects to flat objects

In this post under MapStruct, I will show with example how to map hierarchical objects properties to flat object. In all my previous posts under MapStruct, the source object didn’t compose another object. In other words, there was no object hierarchy. In this post I will use a source object which has a hierarchy as…… Continue reading Mapping hierarchical objects to flat objects

Accessing list in SpEL

In this post under Spring SpEL, I will show with example how to access list in SpEL. For our example I will create the below main class Main class 1 package spel.package4; 2 3 import org.springframework.beans.factory.annotation.Value; 4 import org.springframework.context.ApplicationContext; 5 import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 import org.springframework.context.annotation.Bean; 7 import org.springframework.context.annotation.ComponentScan; 8 import org.springframework.stereotype.Component; 9 10 import java.util.ArrayList;…… Continue reading Accessing list in SpEL

Accessing map in SpEL

In this post under Spring SpEL, I will show with example how to access map in SpEL. For our example I will create the below main class Main class 1 package spel.package3; 2 3 import org.springframework.beans.factory.annotation.Value; 4 import org.springframework.context.ApplicationContext; 5 import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 import org.springframework.context.annotation.Bean; 7 import org.springframework.context.annotation.ComponentScan; 8 import org.springframework.context.annotation.Configuration; 9 10 import java.util.HashMap;…… Continue reading Accessing map in SpEL