<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.
xmlns:xsi="http://www. xmlns:context="http://www.
xmlns:aop="http://www. xmlns:tx="http://www.
xmlns:p="http://www.
xsi:schemaLocation="http://www.
http://www.
http://www.
http://www.
http://www.
http://www.
http://www.
http://www.
<!-- 扫描指定的包 -->
<!--<context:component-scan base-package="dao,service"/> -->
<bean id="dataSource" destroy-method="close"
class="com.mchange.v2.
<!--连接数据库的驱动类 -->
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<!--连接数据库的url -->
<property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:orcl" />
<!--连接数据库的用户名 -->
<property name="user" value="scott" />
<!--连接数据库的密码 -->
<property name="password" value="orcl" />
<!--连接池的最大连接数 -->
<property name="maxPoolSize" value="40" />
<!--连接池的最小连接数 -->
<property name="minPoolSize" value="1" />
<!--初始化连接数 -->
<property name="initialPoolSize" value="1" />
<!--连接的最大空闲时间,超时的连接将被丢弃,单位:秒 -->
<property name="maxIdleTime" value="60" />
<!--没有连接可用时,等待连接的时间,单位:毫秒 -->
<property name="checkoutTimeout" value="2000" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.connection.isolation">2</prop>
</props>
</property>
<!-- mappingResource -->
<property name="packagesToScan">
<list>
<value>com.ffs.entitys</value>
</list>
</property>
</bean>
<!-- 使用spring的aop配置,声明式事务管理 -->
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- <tx:annotation-driven transaction-manager="transactionManager"/> -->
<!-- 配置事务通知属性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 定义事务传播属性 -->
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="edit*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="new*" propagation="REQUIRED" />
<tx:method name="set*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="change*" propagation="REQUIRED" />
<tx:method name="get*" propagation="REQUIRED" read-only="true" />
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="load*" propagation="REQUIRED" read-only="true" />
<tx:method name="*" propagation="REQUIRED" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置事务切面 -->
<!-- 事务边界 -->
<aop:config>
<aop:pointcut id="serviceOperation" expression="execution(* dao.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
</aop:config>
<bean id="baseDao" class="com.ffs.dao.impl.BaseDaoImpl" abstract="true">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="entryDao" class="com.ffs.dao.impl.EntryDaoImpl" parent="baseDao"></bean>
<bean id="entryServiceDao" class="com.ffs.service.impl.EntryServiceImpl">
<property name="entryDao" ref="entryDao"></property>
</bean>
<bean id="entryAction" class="com.ffs.action.EntryAction">
<property name="entryServiceDao" ref="entryServiceDao"></property>
</bean>
<bean id="categoryDao" class="com.ffs.dao.impl.CategoryDaoImpl" parent="baseDao"></bean>
<bean id="categoryServiceDao" class="com.ffs.service.impl.CategoryServiceImpl">
<property name="categoryDao" ref="categoryDao"></property>
</bean>
<bean id="categoryAction" class="com.ffs.action.CategoryAction">
<property name="categoryServiceDao" ref="categoryServiceDao"></property>
<property name="entryServiceDao" ref="entryServiceDao"></property>
</bean>
</beans>
这是spring的配置文件