准備使用AOP記錄所有NamedParameterJdbcTemplate操作數據時的所有日志,沒想到出現這個錯誤,折騰了好久,終於找出原因
解決方案:在 aop-config配置添加上:
proxy-target-class="true"
貼上我的配置AOP配置:
<aop:config proxy-target-class="true"> <aop:pointcut id="pointcut" expression="execution(public * org.xx.util.JdbcUtil.*(..))"/> <aop:aspect id="logAspect" ref="logInterceptor"> <aop:before method="before" pointcut-ref="pointcut"/> <aop:after-returning method="afterRunning" pointcut-ref="pointcut"/> </aop:aspect> </aop:config>
按照博客的說法:http://blog.csdn.net/oathevil/article/details/7244694
注意:proxy-target-class屬性值決定是基於接口的還是基於類的代理被創建。如果proxy-target-class 屬性值被設置為true,那么基於類的代理將起作用(這時需要cglib庫)。如果proxy-target-class屬值被設置為false或者這個屬性被省略,那么標准的JDK 基於接口的代理