Invoking Constructors in SpEL

In this post under Spring SpEL, I will show with example how to invoke constructors. Below is the complete code for your reference Main class 1 package spel.package9; 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.context.annotation.Configuration; 8 import java.util.List; 9 10 @Configuration 11 @ComponentScan(basePackages = “spel.package9”) 12…… Continue reading Invoking Constructors in SpEL

Invoking static methods in SpEL

In this post under Spring SpEL, I will show with example how to invoke static method in SpEL. In SpEL expression, to inform Spring that we are calling static method of class, we use T operator. T operator followed by class name within paranthesis informs the Spring to use Class object of the specified class.…… Continue reading Invoking static methods in SpEL

Invoking object’s non-static methods in SpEL

In this post under Spring SpEL, I will show with example how to call an instance’s non-static method. Below is the complete code for your reference. Main class 1 package spel.package7; 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 @Configuration 10 @ComponentScan(basePackages = “spel.package7”) 11…… Continue reading Invoking object’s non-static methods in SpEL

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

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

Accessing array in SpEL

In this post under Spring SpEL, I will show how to access array elements in SpEL expressions. For our example I will use the two beans. Below is the class structure of them Bean1 class package spel.package2; import org.springframework.stereotype.Component; @Component public class Bean1 { private int[] values = new int[] {1, 2, 3, 4}; public…… Continue reading Accessing array in SpEL

SpEL Simple example

In this post under Spring SpEL, I will give a simple example that shows how to access bean properties and use literal values in SpEL expressions. SpEL (Spring Expression Language) is an expression language that supports querying and manipulating objects at runtime. This expression language is written within “${ and “}” when used inside annotation…… Continue reading SpEL Simple example

Spring @Value annotation

In this post under Spring Core, I will show with example how to use “@Value” annotation. In previous post I showed how to access system properties, environment properties, custom properties using “Environment” interface. In all these case we had to explicitly retrieve the value as shown below and are not injected into the bean automatically…… Continue reading Spring @Value annotation