aop配置

本文介绍了一个使用Spring框架进行依赖注入及面向切面编程(AOP)的配置案例。配置中涉及了DAO层、业务层和服务层组件,并通过AOP对特定方法进行前置通知。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?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-2.5.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

	<bean id="dao" class="cn.veryedu.dao.impl.AccountsTabDAOImpl">
	</bean>
	
	<bean id="service" class="cn.veryedu.service.impl.AccountsTabServiceImpl">
		<property name="dao">	
			<ref local="dao"/>
		</property>
		<property name="manager">
			<ref local="manager"/>
		</property>
	</bean>
	 
	<bean id="action" class="cn.veryedu.action.AccountAction" abstract="true">
		<property name="service">
			<ref local="service"/>
		</property>
	</bean>
	
	<bean id="manager" class="cn.veryedu.transaction.TransactionManager">
	</bean>
	
	<bean name="/queryAccount" parent="action"></bean>
	<bean name="/modifyAccount" parent="action"></bean>
	
	<bean id="logAdvice" class="cn.veryedu.advice.LogAdvice"/>
	
	<aop:config>
		<aop:pointcut id="logPointcut" expression="execution(* cn.veryedu.service.*.modify*(..))"/>
		<aop:pointcut id="logPointcut2" expression="execution(* cn.veryedu.service.*.query*(..))"/>
		<!-- 定义一个可以被使用的切面 
		<aop:aspect id="logAspect" ref="logAdvice">
			<aop:before method="printLog" pointcut-ref="logPointcut"/>
		</aop:aspect>-->
		<aop:aspect id="logAspect" ref="logAdvice">
			<aop:before method="printLog" pointcut-ref="logPointcut2"/>
		</aop:aspect>
	</aop:config>
</beans>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值