spring

1.下载spring并添加到项目中
commons-loggin-1.2.jar
log4j-1.2.17.jar
spring-beans-3.2.13.RELEASE.jar
spring-context-3.2.13.RELEASE.jar
spring-core-3.2.13.RELEASE.jar
spring-expression-3.2.13.RELEASE.ja
2.编写Spring配置文件

<?xml version="1.0" encoding="utf-8" ?>


<!--扫描包中注解标注的类-->
<context:component-scan base-package="cn.zhiyi.service,cn.zhiyi.dao,cn.zhiyi.aop"/>
<!--<bean class="aop.UserServiceLogger"/>-->

<bean class="cn.zhiyi.aop.UserServiceLogger"/>
<aop:aspectj-autoproxy/>
<!--Dao-->
<!--<bean id="dao" class="cn.zhiyi.dao.UserDaoImpl"></bean>-->

<!--Service-->
<!--<bean id="service" class="cn.zhiyi.service.UserServiceImpl" p:dao-ref="dao">-->
<!--&lt;!&ndash;<property name="dao" ref="dao"/>&ndash;&gt;-->
<!--&lt;!&ndash;通过定义的单参数构造方法为userService的dao属性赋值&ndash;&gt;-->
<!--<constructor-arg>-->
<!--&lt;!&ndash;引用id为userDao的对象为userService的dao属性赋值&ndash;&gt;-->
<!--<ref bean="dao"/>-->
<!--</constructor-arg>-->
<!--</bean>-->

<!--Logger-->
<!--<bean id="userLogger" class="cn.zhiyi.aop.UserServiceLogger"/>-->
<!--<bean id="theLogger" class="cn.zhiyi.aop.ErrorLogger"/>-->
<!--<bean id="afterLogger" class="cn.zhiyi.aop.AfterLogger"/>-->
<!--<bean id="aroundLogger" class="cn.zhiyi.aop.AroundLogger"/>-->

<!--<aop:config>-->
<!--定义一个切入点表达式,并命名为“pointcut”-->
<!--<aop:pointcut id="pointcut" expression="execution(public * addNewUser(cn.zhiyi.entity.User))"/>-->
<!--引用包含增强方法的bean-->
<!--<aop:aspect ref="userLogger">-->
<!--将before()方法定义前置增强并引用pointcut切入点-->
<!--<aop:before method="before" pointcut-ref="pointcut"></aop:before>-->
<!--将afterReturning()方法定义后为后置增强并引用pointcut切入点-->
<!--通过returning属性指定为名为result的参数注入返回值-->
<!--<aop:after-returning method="afterReturning" pointcut-ref="pointcut" returning="result"/>-->
<!--</aop:aspect>-->
<!--</aop:config>-->

<!--<aop:config>-->
<!--<aop:pointcut id="pointcut" expression="execution(* cn.zhiyi.service.UserService.*())"/>-->
<!--将afterThrowing()方法定义为异常抛出增强并引用pointcut切入点-->
<!--<aop:aspect ref="theLogger">-->
<!--<aop:after-throwing method="afterThrowing" pointcut-ref="pointcut" throwing="e"/>-->
<!--</aop:aspect>-->
<!--</aop:config>-->
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值