AOP使用小记

如果pointcut中的servic在spring的IOC容器中已经声明,则声明AOP的时候加上属性proxy-target-class="true",否则会出现No unique bean of type is defined异常。

正确的例子如下:

<aop:config proxy-target-class="true">
  <aop:pointcut id="allManagerMethod"
   expression="execution(* ..*.services.impl..*.*(..))" />
  <aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice" />
 </aop:config>

<bean id="ynServices" class="com.server.services.impl.YNServicesImpl">
  <property name="serviceDao" ref="serviceDao" />
 </bean>

services.impl包里面的类已经声明。

猜你喜欢

转载自21jhf.iteye.com/blog/1571568
今日推荐