ITeye博客

AOP使用小记

21jhf · 2012-06-30 16:04 · spring · 开源软件 · Markdown

如果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包里面的类已经声明。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。