<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!--开启注解包-->
<context:component-scan base-package="cn.kgc"></context:component-scan>
<!--dao层 需要注入queryRunner-->
<bean id="queryRunner" class="org.apache.commons.dbutils.QueryRunner">
<!--<constructor-arg type="javax.sql.DataSource" ref="dataSource"></constructor-arg>-->
</bean>
<!--需要dataSource-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driver}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<!--引入外部属性文件-->
<context:property-placeholder location="jdbc.properties"></context:property-placeholder>
<!--使用aop 解决事物问题
事物管理器 : 通知对象
-->
<aop:config>
<!--配置切面-->
<aop:aspect ref="trsnsactionManager">
<!--切入点-->
<aop:pointcut id="pointcut" expression="execution(* cn.kgc.service.impl.*.*(..))"></aop:pointcut>
<!--织入-->
<!--前置增强 开启事物-->
<aop:before method="beginTransaction" pointcut="execution(* cn.kgc.service.impl.*.*(..))"></aop:before>
<!--后置增强 提交事物-->
<aop:after-returning method="commit" pointcut-ref="pointcut"></aop:after-returning>
<!--异常增强 回滚事物-->
<aop:after-throwing method="rollback" pointcut-ref="pointcut"></aop:after-throwing>
<!--最终增强 释放资源-->
<aop:after method="release" pointcut-ref="pointcut"></aop:after>
</aop:aspect>
</aop:config>
</beans>