<?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. Selenium+TestNG+Maven+Jenkins+SVN(转载)

    转载自:https://blog.csdn.net/u014202301/article/details/72354069 一. 创建Maven项目,下载Selenium和TestNG的依赖(依赖可以 ...

  2. git pre-push hook

    This article introduces git pre-push hook. Problem In Lean project, we use a modified version of Goo ...

  3. MMU二级页表

    https://blog.csdn.net/forDreamYue/article/details/78887035

  4. 算法练习LeetCode初级算法之其他

    位1的个数 解法一: class Solution { // you need to treat n as an unsigned value public int hammingWeight(int ...

  5. 51-迷宫(一)- java版dfs和bfs

    一天蒜头君掉进了一个迷宫里面,蒜头君想逃出去,可怜的蒜头君连迷宫是否有能逃出去的路都不知道. 看在蒜头君这么可怜的份上,就请聪明的你告诉蒜头君是否有可以逃出去的路. 输入格式 第一行输入两个整数 nn ...

  6. MongoDB设置连接池操作百万级以上数据

    开发环境 spring 4.3.7 + springBoot 1.5.2 + dubbo 2.6.5 + mongoDB 4.0.0 连接池配置 mongo-pool.properties sprin ...

  7. Java几种常用JSON库性能比较

    本篇通过JMH来测试一下Java中几种常见的JSON解析库的性能. 每次都在网上看到别人说什么某某库性能是如何如何的好,碾压其他的库.但是百闻不如一见,只有自己亲手测试过的才是最值得相信的. JSON ...

  8. IDEA访问不到SpringBoot项目webapp下的内容

    参考:https://blog.csdn.net/weixin_43105335/article/details/87863847 https://blog.csdn.net/qq_34797335/ ...

  9. java 将指定文件夹递归的进行zip打包压缩

    package tmp.MavenTest; import java.io.BufferedInputStream; import java.io.File; import java.io.FileI ...

  10. Python中的计时器对象

    计时器对象用于特定时间运行的操作.往往被安排到特定的单独的线程上运行, 但是计时器初始化的时间间隔可能不是解释器实际执行操作时的实际时刻, 因为线程调度程序负责实际调度与计时器对象相对应的线程. Ti ...