Aop

AOP

面向切面编程
aspect 切面
pointcut 切点
joinpoint 连接点
advice 通知
advisor 适配器
wave 织入
compoent 组件
scan 扫描

自动扫描、注解

1.配置文件

<beans xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.1.xs"    >

<context:component-scan base-package="com.dao,com.service"></context:component-scan>

2.注解
@Repository("Dao") @Service("Service")
@Component("bean") @Controller("Action")

3.依赖注入 @Autowired

优点:简化bean配置

AOP切面

实例化切面

<bean id="aopUtils" class="com.util.AopUtils"></bean>

Aop配置

<aop:config>
        <!--切点配置 -->
        <aop:pointcut id="pointcut" expression="execution(public * com.service..*(..))" />
        <!-- 切面功能配置与切面点组装 -->
        <aop:aspect ref="aopUtils">
            <aop:around method="around" pointcut-ref="pointcut" />
        </aop:aspect>
    </aop:config>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 本博中关于spring的文章:Spring IOC和AOP原理,Spring事务原理探究,Spring配置文件属性...
    Maggie编程去阅读 9,534评论 0 34
  • 因为工作需求,自己去了解一下aop并做下的记录,当然大部分都是参考他人博客以及官方文档。 目录 [关于 AOP](...
    forip阅读 6,729评论 1 20
  • AOP实现可分为两类(按AOP框架修改源代码的时机): 静态AOP实现:AOP框架在编译阶段对程序进行修改,即实现...
    数独题阅读 6,854评论 0 22
  • **** AOP 面向切面编程 底层原理 代理!!! 今天AOP课程1、 Spring 传统 AOP2、 Spri...
    luweicheng24阅读 5,237评论 0 1
  • 晚间打卡 2016/09/23 24/70 今天继续看《如何阅读一本小说》第41-72页,关于小说的虚构,引用书中...
    婉琳阅读 2,675评论 0 0