1.导包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
2。方式一:手动
2.1配置事务.xml
<!-- 配置事物管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<aop:config>
<aop:pointcut expression="execution(* cn.itsource.web.controller.service..*.*(..))" id="coreServicePointcut"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="coreServicePointcut"/>
</aop:config>
<!-- aop应用事务管理 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="select*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
2.2主配置类加注解
...
@ImportResource("classpath:applicationContext-service.xml")
public class ApplicationConfig
网友评论