Spring Core

Have some option configure to get Data sources.

1. Data sources are defined by JDBC driver:

<bean id=”dataSource” class=”DriverManagerDataSource”>
<property name=”driverClassName” value=”jdbcDriver” />
<property name=”url” value=”url” />
<property name=”username” value=”user” />
<property name=”password” value=”pass” />

Use DriverManagerDataSource class.

Returns a new connection every time that a connection is requested.

2. Data sources are gotten from pool connections:

– Data sources are looked up by JDNI.


Before use it .You have to register an AutowiredAnnotationBeanPostProcessor instance in the IOC container.

-Have two way to register:

1. <context:annotation-config>

2. <bean class=”org.springframework.beans

.factory.annotation.AutowiredAnnotationBeanPostProcessor” />

Different  between @Autowired and @Resource:

– @Autowired wires by Type and specified by Spring . If you want to use wires by Name . Add @Qualifier.

-@Resource wires by Name and specified by Java

Spring provides two type of Spring IOC container : BeanFactory and ApplicationContext.

Bean Factory

  • Bean instantiation/wiring

Application Context

  • Bean instantiation/wiring
  • Automatic BeanPostProcessor registration
  • Automatic BeanFactoryPostProcessor registration
  • Convenient MessageSource access (for i18n)
  • ApplicationEvent publication