El nucleo de Spring Framework es su Inversion of Control (IoC) Container , su trabajo es instanciar, inicializar y (wire up) objectos de la aplicacion.
Los objectos que forman parte del backbone de su aplicacion y que son manejados por Spring Container son llamados beans (Java objects) tambien conocidos como POJOs.
El Spring Container necesita informacion de como se va instanciar, inicializar sus beans. Esta configuracion es llamada configuration metadata.
Existen dos maneras de realizar esta configuracion a traves de un archivo XML o llamado Annotation‐based:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="accountService" class="com.fredo.AccountServiceImpl">
<property name="accountDao" ref="accountDao"/>
</bean>
<bean id="accountDao" class="com.fredo.AccountDaoInMemoryImpl">
<!-- dependencies of accountDao will be defined here -->
</bean>
</beans>
O definiendo una clase Java anotada con @Configuration
Java‐based:
@Configuration
public class Ch2BeanConfiguration {
@Bean
public AccountService accountService() {
AccountServiceImpl bean = new AccountServiceImpl();
bean.setAccountDao(accountDao());
return bean;
}
@Bean
public AccountDao accountDao() {
AccountDaoInMemoryImpl bean = new AccountDaoInMemoryImpl();
//depedencies of accountDao bean will be injected here...
return bean;
}
}

