Spring @Import Annotation

This post shows how to use @Import annotation in Spring. In an application you may have several bean definitions making your @Configuration class quite huge. Rather than putting all the bean definitions in a single configuration class you can break your configuration into several small configurations module wise. Then using…

Continue reading

Spring @Conditional Annotation

Using Spring @Conditional annotation you can conditionally register a component. With @Conditional annotation you need to specify a condition and the component is registered only if the condition is true. For specifying the condition you need to implement org.springframework.context.annotation.Condition interface. Where to use @Conditional annotation The @Conditional annotation may be…

Continue reading

Spring @Value Annotation

Spring @Value annotation at the field or method/constructor parameter level is used to inject a value. @Value annotation in Spring can be used in the following ways- Directly to inject a value at the field, method or constructor level. Using @Value annotation you can also assign a value by reading…

Continue reading

Spring Expression Language (SpEL) Tutorial

The Spring Expression Language (“SpEL”) is an expression language that supports querying and manipulating an object graph at runtime. In this post we’ll see examples of using SpEL with both XML and annotation based configuration. The expression language supports the following functionality: Literal expressions Boolean, relational and mathematical operators Regular…

Continue reading