Spring 3 and JSR-330 @Inject and @Named example
Since Spring 3.0, Spring supports for the standard JSR 330: Dependency Injection for Java. In Spring 3 application, you can uses standard: 1 - @Inject instead of Spring’s @Autowired to…
Spring DI via setter method
A simple Spring example to show you how to dependency inject a bean via setter method, the most common used DI method.
Spring Dependency Injection (DI)
In Spring frameowork, Dependency Injection (DI) design pattern is used to define the object dependencies between each other. It exits in two major types : 1 - Setter Injection -…
[org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
Follow the Stackoverflow question about: Spring/Java error: namespace element 'annotation-config' ... on JDK 1.5 and higher to find the solution for fixing the error: java.lang.IllegalStateException: Context namespace element 'annotation-config' and…
Spring DI via constructor
Uses Spring to dependency inject a bean via constructor. 1. IOutputGenerator An interface and implementation class of it. 2. Helper class A helper class, later use Spring to DI the…
Spring Autowiring @Qualifier example
In Spring, @Qualifier means, which bean is qualify to autowired on a field. When you have multiple similar beans are declared in bean configuration file, will Spring know which particular…
Spring Auto-Wiring Beans with @Autowired annotation
In last Spring auto-wiring in XML example, it will autowired the matched property of any bean in current Spring container. In most cases, you may need autowired property in a…
Spring Autowiring by AutoDetect
In Spring, “Autowiring by AutoDetect“, means chooses “autowire by constructor” if default constructor (argument with any data type), otherwise uses “autowire by type“.
Spring Autowiring by Constructor
In Spring, “Autowiring by Constructor” is actually autowiring by Type in constructor argument. It means, if data type of a bean is same as the data type of other bean…
Spring Autowiring by Type
In Spring, “Autowiring by Type” means, if data type of a bean is compatible with the data type of other bean property, auto wire it. For example, a “person” bean…