spring入門-AOP 面向切面編程
阿新 • • 發佈:2017-07-21
面向 das let cau pri log exce lib xxx
AOP 面向切面編程
在日常開發中最後將業務邏輯定義在一個專門的service包下,而實現定義在service包下的impl包中,
服務接口以IXXXService形式,而服務實現就是XXXService,這就是規約設計
步驟:
1.E:\Users\WorkSpaces\KmwalletApp\spring\aop\test\HelloWorldService.java 繼承(implements)xx接口
2.E:\Users\WorkSpaces\KmwalletApp\spring\aop\test\IHelloWorldService.java 定義接口方法
3.HelloWorldService 實現接口方法
E:\Users\WorkSpaces\KmwalletApp\spring\aop\test\HelloWorldAspect.java定義切面
E:\Users\WorkSpaces\KmwalletApp\spring\aop\test\AopTest.java 測試運行
坑:
1.xml放置位置
關鍵詞
ClassPathXmlApplicationContext
2.缺少jar包
Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
你缺少了 aspectj.jar啊!
看異常很清楚了。
好了,過程就是這樣,剩下的就是理解了
spring入門-AOP 面向切面編程