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

spring使用aop时xml中的配置

2014-11-03 13:48 369 查看
<?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"
xmlns:p="http://www.springframework.org/schema/p"
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 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd ">

<bean id="userServer" class="com.hcj.service.impl.UserServiceImpl" init-method="init" destroy-method="destroy">
<property name="userDao" ref="userDao"></property>
<!-- <constructor-arg>
<ref bean="userDao"/>
</constructor-arg> -->
</bean>
<bean id="userDao" class="com.hcj.dao.impl.UserDaoImpl">
<property name="set">
<set>
<value>123</value>
<value>456</value>
<value>789</value>
</set>
</property>

<property name="list">
<list>
<value>a</value>
<value>b</value>
<value>c</value>
</list>
</property>

<property name="map">
<map>
<entry key="44" value="aa">

</entry>
<entry key="55" value="bb">

</entry>
</map>
</property>

</bean>

<bean id="daoLog" class="com.hcj.log.DaoLog"></bean>

<aop:config>
<!-- 切入点 -->
<aop:pointcut expression="execution(public void com.hcj.dao.impl.UserDaoImpl.save(..))" id="pointcut"/>
<aop:aspect ref="daoLog">
<aop:before method="beforeMethod" pointcut-ref="pointcut"/>
<!-- <aop:after method="afterMethod" pointcut-ref="pointcut"/> -->
<aop:after-throwing method="afterMethod" pointcut-ref="pointcut"/>
<!-- <aop:after-returning method="afterMethod" pointcut-ref="pointcut"/> -->
</aop:aspect>
</aop:config>

</beans>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  aop xml spring