Sping 代理配置

我的spring中总共有两个代理,一个是事务的代理(日志事务切面)。一个是日志操作的代理(用注解实现的切面)

但是弄完之后,总是报一个代理异常的错误,具体错误忘记了,整理如下

spring默认的注入为接口注入方式,所以说如果你的类是 private class className;

   这样的注入是不行的,应该是 private interface className;

。如果我们想用实现类进行注入需要:

1、导入CGLIB库,即cglib.jar

2、在spring配置文件applicationContext.xml中进行一下配置:<aop:aspectj-autoproxy proxy-target-class="true"/>

3、事务

  <aop:config proxy-target-class="true">

当然cjlib-node*(具体忘了,也是可以的)

红色部分为重点

猜你喜欢

转载自smartzjp.iteye.com/blog/1166354