View RSS Feed

Spring Framework

SpringSource Spring Framework tutorials and examples. Focusing on Spring 3 and above.

  1. How to Automatically Discover Spring Beans on the Classpath

    by , 11-27-2011 at 09:38 PM
    Since itís appearance in Java 5, annotations has helped to simplify the configuration of application through component scanning. This removes the need for XML bean tags in many cases. Classes annotated as component stereotypes including the following: @Service, @Controller, @Configuration, @Component, @Repository as well as the JSR-330 annotations, such as @Named are included in the auto-scan default filter. Once auto-detected, these components become Spring beans and are automatically placed ...
  2. How to Autowire a Spring Bean

    by , 11-16-2011 at 04:23 PM
    In previous tips, we have shown how to wire beanís properties using the <property> element. There is an alternative approach that can be used. Itís called autowiring. In this approach, Spring will wire your beans automatically if you set the autowire property on each <bean> on each of the beans that you want to autowire. There are four types of autowiring that Spring uses:

    • byNameóSpring will attempt to find a bean in the container whose name (or ID) is the same as the
  3. Wiring Lists and Arrays in Spring Beans

    by , 11-16-2011 at 04:17 PM
    Often you will have situations where you will need to wire properties that are lists or arrays. If you are using Hibernate jointly with Spring, you will need to se this in order to provide the list of Hibernate mapping files. In order to do this, you will use the <list> element to wire the property in the wiring XML file for either an array property or a java.util.List property.

    For example, when you want to map Hibernate mapping files, you will wire a LocalSessionFactoryBean ...
    Bean , Configuration
  4. The Lifecycle of a Spring Bean

    by , 11-16-2011 at 04:11 PM
    In this tip, we will look at the lifecycle of a bean. The bean lifecycle for a Spring bean is somewhat complex. It is important to understand the life cycle of a Spring bean. Otherwise it will be difficult for you as a programmer to use Spring to its full abilities especially because you may want to take advantage of some of the opportunities that Spring offers to customize how a bean is created. The startup life cycle of a typical bean as it is loaded into a BeanFactory container is shown: ...