Spring Bean

Spring Autowire Use @Component, @Repository, @Service and @Controller Annotations

Besides define Spring beans in configuration file, Spring also provide some java annotation interface for you to make Spring bean declaration simple and easy. These interfaces are also called stereotype annotation. They are @Component, @Repository, @Service and @Controller. If you want to reference such a bean, you just need to annotate that field with @Autowired …

Spring Autowire Use @Component, @Repository, @Service and @Controller Annotations Read More »

Spring Event Publisher / Listener Example

Spring event architecture make event publish and receive so easy. You can just configure event publisher and listener object as Spring beans in application context xml file. And then use them to send and receive event in your java code. This method decoupled java event object relationship if you hardcode them in java application. This …

Spring Event Publisher / Listener Example Read More »

Spring FactoryBean Example

Spring FactoryBean is a special beans in spring framework. It can be used as a bean factory to create other Spring managed beans. You may be already familiar with built-in FactoryBean such as JndiObjectFactoryBean which is used to lookup jndi object, LocalSessionFactoryBean which is used to create hibernate session object, but this article will tell …

Spring FactoryBean Example Read More »

Autowire Spring Bean By Name Examples

Besides declare spring bean dependencies in bean configuration file, spring framework provide autowire function to make bean dependency declaration easily. There are below autowire modes, they are no autowire, by bean name, by bean class type, by constructor. This article will show you examples about autowire bean by name.