code前行

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

通过XML的方式引入新功能

xml 配置

<bean id="performance" class="springAop.PerformanceImpl"/>
<bean id="encoreable" class="springAop.EncoreableImpl"/>
        
<!-- 有两种方式引入接口的实习,这里用的是 default-impl 属性,还可以使用  delegate-ref 属性
如:delegate-ref = "beanId"
注意 springAop.Performance+ 结尾的"+";加号表示是 Performance的所有子类,而不是Performance本身  不加+会报错类型转换异常
-->
 <aop:config>
    <aop:aspect>
     <aop:declare-parents types-matching="springAop.Performance+" implement-interface="springAop.Encoreable" default-impl="springAop.EncoreableImpl"/>
    </aop:aspect>
 </aop:config>

 注入AspectJ切面

安装AJDT插件戳这里:安装插件AJDT

1新建 aspect 工程

 

2创建一个切面

3导入包

4注入依赖

 

posted on 2018-03-17 16:40  code前行  阅读(148)  评论(0)    收藏  举报