<!--配置AOP通知-->
<tx:advice id="txAdvice" transaction-manager="dataSourceTransactionManager">
<!--配置事务属性-->
<tx:attributes>
<!--添加事务管理的方法-->
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="append*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="edit*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="remove*" propagation="REQUIRED"/>
<tx:method name="repair" propagation="REQUIRED"/>
<tx:method name="get*" propagation="REQUIRED" read-only="true"/>
<tx:method name="find*" propagation="REQUIRED" read-only="true"/>
<tx:method name="load*" propagation="REQUIRED" read-only="true"/>
<tx:method name="search*" propagation="REQUIRED" read-only="true"/>
<!--SUPPORTS:有没有事务都可以-->
<tx:method name="select*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice>
配置了Spring AoP,启动项目报错:
org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException
原因:
Spring AOP
虽然有自己的AOP功能,但是它是依赖AspectJ来实现的。使用maven搭建的项目pom.xml中,没有引入aspectjweaver包。
解决:在pom.xml添加依赖即可
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.2</version>
</dependency>