您的位置:首页 > 编程语言 > Java开发

spring_由XML实现AOP面向切面编程_实现动态代理

2017-05-24 16:26 826 查看
<?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"
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/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> 
<context:annotation-config />
<!-- 自动扫描初始化对象 -->
<context:component-scan base-package="com.bjsxt" />

<!-- 初始化该切面类 -->
<bean id="logInterceptor" class="com.bjsxt.aop.LogInterceptor"></bean>
<aop:config>
<!-- 全局切面逻辑范围 -->
<aop:pointcut expression="execution(public * com.bjsxt.dao..*.*(..))"
id="daoPointcut" />
<!-- 声明一个切面对象 -->
<aop:aspect id="logAspect" ref="logInterceptor">
<!-- 在方法执行之前要执行哪个方法 -->
<aop:before method="brefore" pointcut-ref="daoPointcut" />
</aop:aspect>
</aop:config>
</beans>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐