SpringAOP配置
来源:互联网 发布:淘宝卖家怎么看运费险 编辑:程序博客网 时间:2024/06/03 15:58
<?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:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->
<!-- 配置客户的dao -->
<bean id="customerDao" class="cn.feicui.demo3.CustomerDaoImpl"/>
<!-- 编写切面类配置好 -->
<bean id="myAspectXml" class="cn.feicui.demo3.MyAspectXml"/>
<!-- 配置AOP -->
<aop:config>
<aop:aspect ref="myAspectXml">
<!-- <aop:before method="log" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- 配置最终通知
<aop:after method="after" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/>
-->
<!-- <aop:after-returning method="afterReturn" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- 环绕通知 -->
<aop:around method="around" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/>
</aop:aspect>
</aop:config>
</beans>
<?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:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->
<!-- 配置客户的dao -->
<bean id="customerDao" class="cn.feicui.demo3.CustomerDaoImpl"/>
<!-- 编写切面类配置好 -->
<bean id="myAspectXml" class="cn.feicui.demo3.MyAspectXml"/>
<!-- 配置AOP -->
<aop:config>
<aop:aspect ref="myAspectXml">
<!-- 切入点的表达式
1. execution() 固定的,不能不写
2. public 可以省略不写
3. void,返回值可以出现 * 表示任意的返回值,返回值类型不能不写
4. 可以使用 * 代替的,不能不编写的,简写方式:*..*方法
5. *DaoImpl
6. 方法 save*
7. 方法的参数:
-->
<!-- <aop:before method="log" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- public 可以省略不写 -->
<!-- <aop:before method="log" pointcut="execution(void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- void,返回值可以出现 * 表示任意的返回值,返回值类型不能不写 -->
<!-- <aop:before method="log" pointcut="execution(* cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- 包名可以使用 * 代替,不能不写 -->
<!-- <aop:before method="log" pointcut="execution(* cn.feicui.*.CustomerDaoImpl.save())"/> -->
<!-- 包的简写的方式,任意的包的结构 -->
<!-- <aop:before method="log" pointcut="execution(* *..*.CustomerDaoImpl.save())"/> -->
<!-- 编写类的写法 -->
<!-- <aop:before method="log" pointcut="execution(* *..*.*DaoImpl.save())"/> -->
<!-- 方法编写 -->
<!-- <aop:before method="log" pointcut="execution(* *..*.*DaoImpl.save*())"/> -->
<!-- 参数列表:出现一个*,表示一个参数,任意参数使用 .. -->
<aop:before method="log" pointcut="execution(* *..*.*DaoImpl.save*(..))"/>
</aop:aspect>
</aop:config>
</beans>
<?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:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->
<!-- 把custom类交给spring管理 -->
<bean id="customerDao"
class="cn.feicui.demo3.CustomerDaoImpl"/>
<!-- 编写切面类配置好 -->
<bean id="myAspectXml"
class="cn.feicui.demo3.MyAspectXml"/>
<!-- 配置AOP -->
<aop:config>
<!-- 配置切面类:切入点 + 通知(类型) -->
<aop:aspect ref="myAspectXml">
<!-- 配置的前置通知,save方法执行之前,增强的方法会执行 -->
<!-- 切入点的表达式:execution(public void cn.feicui.demo3.CustomerDaoImpl.save()) -->
<!-- <aop:after-returning method="afterReturn" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<aop:around method="around" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/>
</aop:aspect>
</aop:config>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->
<!-- 配置客户的dao -->
<bean id="customerDao" class="cn.feicui.demo3.CustomerDaoImpl"/>
<!-- 编写切面类配置好 -->
<bean id="myAspectXml" class="cn.feicui.demo3.MyAspectXml"/>
<!-- 配置AOP -->
<aop:config>
<aop:aspect ref="myAspectXml">
<!-- <aop:before method="log" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- 配置最终通知
<aop:after method="after" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/>
-->
<!-- <aop:after-returning method="afterReturn" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- 环绕通知 -->
<aop:around method="around" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/>
</aop:aspect>
</aop:config>
</beans>
<?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:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->
<!-- 配置客户的dao -->
<bean id="customerDao" class="cn.feicui.demo3.CustomerDaoImpl"/>
<!-- 编写切面类配置好 -->
<bean id="myAspectXml" class="cn.feicui.demo3.MyAspectXml"/>
<!-- 配置AOP -->
<aop:config>
<aop:aspect ref="myAspectXml">
<!-- 切入点的表达式
1. execution() 固定的,不能不写
2. public 可以省略不写
3. void,返回值可以出现 * 表示任意的返回值,返回值类型不能不写
4. 可以使用 * 代替的,不能不编写的,简写方式:*..*方法
5. *DaoImpl
6. 方法 save*
7. 方法的参数:
-->
<!-- <aop:before method="log" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- public 可以省略不写 -->
<!-- <aop:before method="log" pointcut="execution(void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- void,返回值可以出现 * 表示任意的返回值,返回值类型不能不写 -->
<!-- <aop:before method="log" pointcut="execution(* cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<!-- 包名可以使用 * 代替,不能不写 -->
<!-- <aop:before method="log" pointcut="execution(* cn.feicui.*.CustomerDaoImpl.save())"/> -->
<!-- 包的简写的方式,任意的包的结构 -->
<!-- <aop:before method="log" pointcut="execution(* *..*.CustomerDaoImpl.save())"/> -->
<!-- 编写类的写法 -->
<!-- <aop:before method="log" pointcut="execution(* *..*.*DaoImpl.save())"/> -->
<!-- 方法编写 -->
<!-- <aop:before method="log" pointcut="execution(* *..*.*DaoImpl.save*())"/> -->
<!-- 参数列表:出现一个*,表示一个参数,任意参数使用 .. -->
<aop:before method="log" pointcut="execution(* *..*.*DaoImpl.save*(..))"/>
</aop:aspect>
</aop:config>
</beans>
<?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:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->
<!-- 把custom类交给spring管理 -->
<bean id="customerDao"
class="cn.feicui.demo3.CustomerDaoImpl"/>
<!-- 编写切面类配置好 -->
<bean id="myAspectXml"
class="cn.feicui.demo3.MyAspectXml"/>
<!-- 配置AOP -->
<aop:config>
<!-- 配置切面类:切入点 + 通知(类型) -->
<aop:aspect ref="myAspectXml">
<!-- 配置的前置通知,save方法执行之前,增强的方法会执行 -->
<!-- 切入点的表达式:execution(public void cn.feicui.demo3.CustomerDaoImpl.save()) -->
<!-- <aop:after-returning method="afterReturn" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/> -->
<aop:around method="around" pointcut="execution(public void cn.feicui.demo3.CustomerDaoImpl.save())"/>
</aop:aspect>
</aop:config>
</beans>
阅读全文
0 0
- springAOP配置
- SpringAOP配置
- SpringAOP配置事务
- springAop基于注解配置
- springAOP的配置及实例
- SpringAOP的几种配置
- SpringAOP
- SpringAOP
- SpringAop
- SpringAOP
- springAOP
- springAOP
- SpringAOP
- SpringAop
- springAOP
- springAOP
- SpringAop
- SpringAOP
- Junit4 简单使用及示例代码
- windows系统jdk环境变量配置1.6升级1.7失败
- 【Leetcode】81. Search in Rotated Sorted Array II
- 记一次线上请求缓慢问题处理
- Java总结篇系列:Java多线程(一)
- SpringAOP配置
- python学习learning_curve和validation_curve
- 先安装keras、TensorFlow后使用Anaconda安装Jupyter
- web开发第五课信息存储到数据库
- 关于分布式事务、两阶段提交、一阶段提交、Best Efforts 1PC模式和事务补偿机制的研究
- 联想小新潮7000如何bios设置u盘启动操作
- 也许,这样理解HTTPS更容易
- js判断图片加载完成
- JS中 实现for循环里面睡眠1秒再执行的相同的效果