A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© hy2014051202 中级黑马   /  2017-6-15 10:47  /  881 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.1.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
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd">

        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
                <property name="jdbcUrl" value="jdbc:mysql:///test"></property>
                <property name="user" value="root"></property>
                <property name="password" value="root"></property>
        </bean>

        <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
                <property name="dataSource" ref="dataSource"></property>
        </bean>
        <tx:annotation-driven transaction-manager="transactionManager" />

        <bean id="userService" class="com.test.service.UserService">
                <property name="userDao" ref="userDao"></property>
        </bean>
        <bean id="userDao" class="com.test.dao.UserDao">
                <property name="jdbcTemplate" ref="jdbcTemplate"></property>
        </bean>




        <bean id="transactionManager"
                class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                <property name="dataSource" ref="dataSource"></property>
        </bean>

        <tx:advice id="txAdice" transaction-manager="transactionManager">

                <tx:attributes>

                        <tx:method name="accountMoney" />
                </tx:attributes>
        </tx:advice>

        <aop:config>
                <aop:pointcut expression="execution(* com.test.service.OrederService.*(..))"
                        id="pointcut1" />
                <aop:advisor advice-ref="txAdice" pointcut-ref="pointcut1" />

        </aop:config>


0 个回复

您需要登录后才可以回帖 登录 | 加入黑马