导入spring3.0 所有jar外再加5个包
1.aopalliance-1.0.jar
2.aspectjrt.jar
3.aspectjweaver.jar
4.cglib-nodep-2.1_3.jar
5.commons-logging-1.0.4.jar
applicationContext.xml配置
<aop:config proxy-target-class="true">
<aop:aspect id="aspectlog" ref="log">
<aop:pointcut id="pointMethod" expression="execution(* com.cyberway.spring.*.*(..))" />
<aop:after pointcut-ref="pointMethod" method="addLog"/>
</aop:aspect>
</aop:config>
注:如果生存代理失败需要配置属性 proxy-target-class="true" 默认为false
本文介绍如何在Spring 3.0环境中配置AOP来实现方法调用的日志记录功能。具体步骤包括导入必要的Jar包,如aopalliance、aspectj等,并通过applicationContext.xml文件设置代理和切面,定义切入点及通知方法。
259

被折叠的 条评论
为什么被折叠?



