[Spring] 사무 관리 (데이터 원본) 설정

Spring 트 랜 잭 션 관리 (데이터 원본) 설정
프로필

<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: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.2.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.2.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">


    
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver">property>
        <property name="url" value="jdbc:mysql://localhost:3306/spring3.2_10">property>
        <property name="username" value="root">property>
        <property name="password" value="root">property>
        
        <property name="initialSize" value="1">property>
        
        <property name="maxActive" value="5">property>
        
        <property name="maxIdle" value="2">property>
        
        <property name="minIdle" value="1">property>
    bean>

    <bean id="orderDao" class="com.daoimpl.OrderDaoImpl">
        <property name="dataSource" ref="dataSource">property>
    bean>
    <bean id="detailDao" class="com.daoimpl.DetailDaoImpl">
        <property name="dataSource" ref="dataSource">property>
    bean>

    <bean id="orderService" class="com.serviceimpl.OrderServiceImpl">
        <property name="orderDao" ref="orderDao">property>
        <property name="detailDao" ref="detailDao">property>
        <property name="detailService" ref="detailService">property>
    bean>

    <bean id="detailService" class="com.serviceimpl.DetailServiceImpl">
        <property name="detailDao" ref="detailDao">property>
    bean>


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

    
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            
            <tx:method name="save*" propagation="REQUIRED"/>
            <tx:method name="update*" propagation="REQUIRED"/>
            <tx:method name="query*" read-only="true"/>
        tx:attributes>
    tx:advice>

    
    <aop:config>
        
        <aop:pointcut expression="execution(* com.serviceimpl..*.*(..))" id="mycut"/>
        
        <aop:advisor advice-ref="txAdvice" pointcut-ref="mycut"/>
    aop:config>
beans>

``
``

좋은 웹페이지 즐겨찾기