Search This Blog

Thursday 12 April 2012

The default-autowire attribute

We have seen that Spring supports a variety of auto-wiring options. Spring Container allows us to set a default autowiring for all the beans.
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
    default-autowire="no">
</beans>
By default, the default-autowire attribute is set to no. This means that no beans should be auto wired unless they’re individually configured for autowiring with the autowire attribute. We can still override the default on a bean-by-bean basis using the autowire attribute.
<bean id="carByName" class="com.car.CarByName" autowire="byName"/>

No comments:

Post a Comment