applicationContext.xml配置数据源,事务管理器,sessionFactory
<bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="datasource"/>
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager" >
<property name="sessionFactory"><ref bean="sessionFactory" /></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="userDao" class="com.study.dao.UserDao" >
<property name="sessionFactory"><ref bean="sessionFactory" /></property>
</bean>
<context:component-scan base-package="com.study.*"></context:component-scan>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>