나의 개발 기록/Java /Spring
[Spring] 스프링 AOP 적용 (Transaction)
블랑 블랑
2023. 3. 15. 15:12
반응형
build.gradle
compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.9.7'
servlet.context.xml
<tx:annotation-driven proxy-target-class="true"/>
얘는 <beans:beans> 영역에 추가
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
mybatis.context.xml
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="requiredTx" expression="execution(* com.pangpany.dcaf..*Impl.*(..)) "/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="requiredTx" />
</aop:config>
얘는 <beans:beans> 영역에 추가
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd"
반응형