<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd"> <!--01.我们需要知道给哪个目标对象织入增强
02.需要配置目标对象
03.需要配置增强 通知-->
<!--实例化EatSleepDaoImpl-->
<bean id="eatSleepDao" class="cn.bdqn.dao.EatSleepDaoImpl"/> <!--书写多个目标对象-->
<!--实例化EatSleepServiceImpl-->
<bean id="eatSleepService" class="cn.bdqn.service.EatSleepServiceImpl">
<property name="dao" ref="eatSleepDao"></property>
</bean> <!--切面-->
<bean id="myAspect2" class="cn.bdqn.aop.aop_xml.MyAspect2"/> <!--在xml配置文件里配置aspectJ 最常用-->
<aop:config>
<!--切入点表达式 根据需求配置可以配置多个-->
<aop:pointcut id="myPointcut" expression="execution(* *..service.*.*(..))"/>
<aop:pointcut id="myPointcut2" expression="execution(* *..service.*.sleep(..))"/>
<aop:pointcut id="myPointcut2_around" expression="execution(* *..service.*.eat(..))"/>
<!--指定切面-->
<aop:aspect id="aspect2" ref="myAspect2">
<!--找到myPointcut匹配的方法进行织入-->
<aop:before method="befors" pointcut-ref="myPointcut"></aop:before> <aop:around method="around(org.aspectj.lang.ProceedingJoinPoint)" pointcut-ref="myPointcut2_around"/> <aop:after-throwing throwing="ex" method="excption(java.lang.Exception)" pointcut-ref="myPointcut"/> <aop:after-returning returning="result" method="aftersReturn(java.lang.String)" pointcut-ref="myPointcut" /> <aop:after method="afters" pointcut-ref="myPointcut2"/> </aop:aspect> </aop:config> </beans>

Spring-AspectJ 配置文件的更多相关文章

  1. Spring boot 配置文件详解 (properties 和yml )

    从其他框架来看 我们都有自己的配置文件, hibernate有hbm,mybatis 有properties, 同样, Spring boot 也有全局配置文件. Springboot使用一个全局的配 ...

  2. 史上最全的Spring Boot配置文件详解

    Spring Boot在工作中是用到的越来越广泛了,简单方便,有了它,效率提高不知道多少倍.Spring Boot配置文件对Spring Boot来说就是入门和基础,经常会用到,所以写下做个总结以便日 ...

  3. Spring AspectJ AOP 完整示例

    http://outofmemory.cn/java/spring/AOP/aop-aspectj-example-before-after-AfterReturning-afterThrowing- ...

  4. AOP操作-AspectJ配置文件

    AOP操作(AspectJ配置文件)(了解) (实际中大部分用注解方式) 1,创建两个类,增强类和被增强类,创建方法 2,在spring配置文件中创建两个类对象 3,在spring配置文件中配置切入点

  5. Spring的配置文件

    Web.xml将会配置Spring的配置文件位置: <servlet>        <servlet-name>x</servlet-name>        & ...

  6. java Spring使用配置文件读取jdbc.properties

    Spring使用配置文件读取jdbc.properties 在beans.xml中加入两个必须的bean [html]<bean id="propertyConfigurer" ...

  7. Spring4.0学习笔记(11) —— Spring AspectJ 的五种通知

    Spring AspectJ 一.基于注解的方式配置通知 1.额外引入的jar包: a) com.springsource.org.aopalliance-1.0.0.jar b) com.sprin ...

  8. 使用JDom解析XML文档模拟Spring的配置文件解析

    在J2EE项目中可能会涉及到一些框架的使用,最近接触到了SSH,拿Spring来说配置文件的使用是相当重要的,Spring的配置文件是一个xml文件,Spring是如何读取到配置文件并进行依赖注入的呢 ...

  9. Spring Boot 配置文件详解

    Spring Boot配置文件详解 Spring Boot提供了两种常用的配置文件,分别是properties文件和yml文件.他们的作用都是修改Spring Boot自动配置的默认值.相对于prop ...

  10. Springboot 系列(二)Spring Boot 配置文件

    注意:本 Spring Boot 系列文章基于 Spring Boot 版本 v2.1.1.RELEASE 进行学习分析,版本不同可能会有细微差别. 前言 不管是通过官方提供的方式获取 Spring ...

随机推荐

  1. del_cursor 批量删除游标

    declare   cursor [del_cursor] is select a.*, a.rowid row_id from [table_name] a order by a.rowid;   ...

  2. Python学习—数据库篇之初识mysql

    一.下载与安装 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下公司.MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面MySQL是最好 ...

  3. 配置ESP8266 NONOS SDK时由于工具链版本差异引发的故障

    前几天部署ESP8266_NONOS_SDK时遇到了一个看似奇怪的问题,描述如下: examples例程可以通过编译,但烧写到ESP8266模块后,程序无法正常运行,编译和烧写的相关配置均无误.在bo ...

  4. SpringCloud Hystrix熔断之线程池

    服务熔断 雪崩效应:是一种因服务提供者的不可用导致服务调用者的不可用,并导致服务雪崩的过程. 服务熔断:当服务提供者无法调用时,会通过断路器向调用方直接返回一个错误响应,而不是长时间的等待,避免服务雪 ...

  5. java基础 -- 经典排序

    ----  冒泡排序 方法: 1.每次比较相邻的两个数 2. 小的交换在前面 3.每轮结束后最大的数交换到最后 代码实现: /* * 冒泡排序 * */ public class SortNum { ...

  6. 内网ssh穿透

    公司服务器没有公网IP,只有内网IP,利用自己的阿里云服务器(有公网ip)做ssh内网穿透,使得外网可访问.方法如下: 环境: 公司服务器和阿里云服务器均为 Ubuntu 操作系统, 需要修改阿里云服 ...

  7. CVTE C/C++开发工程师笔试题(二)

    问题描述:打印重复元素 给定一个数组,内容可能包含1到N的整数,N最大为40000,数组可能含有重复的值,且N的取值不定.若只剩余5KB内存可用,请设计函数尽可能快的答应数组中所有重复的元素. voi ...

  8. Android面试准备20190422

    1.即时推送原理,采用的push推送模式,保持一个长连接,服务端和客户端连接后不再断开.所谓长连接,即是在一个TCP上可以连续发送多个数据包,在TCP连接保持期间,如果没有数据包发送,需要双方发送检测 ...

  9. php查询mysql中的json编码后的字符串内容的方法

    问题 mysql里存的是json编码后的字符串,其中中文会被转为unicode码,所以直接查询是查询不到的. mysql里的查询如 like "%\u6211\u662f%" 也是 ...

  10. Redis分布式缓存

    Redis 主 slave 数据库优化-- 加inex, 分区 JVM调优--参数设置,比如偏向于计算的如何设置? 线程池:queue放满了之后,有什么方式能让他不拒绝掉?blockqueue就等在那 ...