zoukankan      html  css  js  c++  java
  • spring中aop以xml配置方式

    1 引jar包

    springAOPaopalliance.jar
    springAOPaspectjrt.jar
    springAOPaspectjweaver.jar
    springAOPspring-aop-3.2.9.RELEASE.jar

    2 aop配置

    <?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-4.3.xsd
             http://www.springframework.org/schema/aop
             http://www.springframework.org/schema/aop/spring-aop.xsd">
            
            <bean id="userDao" class="com.huitong.Dao3.UserDao"></bean>
            <bean id="aop" class="com.huitong.Dao3.Aop"></bean>
            
            <aop:config>
                <aop:pointcut expression="execution(* com.huitong.Dao3.UserDao.*(..))" id="pt"/>
                <aop:aspect id="asp" ref="aop">
                    <aop:around method="around" pointcut-ref="pt"/>
                
                </aop:aspect>
            </aop:config> 
    </beans>

    3 测试

    public void fun2(){
            ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("bean-dao.xml");
            UserDao userDao = (UserDao) ac.getBean("userDao");
            userDao.saveUser();
        }

     注意:sop拦截点定义到方法,所以在写拦截点时要写全。

  • 相关阅读:
    7年Java后端被淘汰,一路北漂辛酸史。。。
    vue jqury如何获取元素中的属性
    02-Elenment 引入使用
    01
    vuex 全局store,前后端交互
    五分钟搞懂Vuex
    VueX 的使用
    vue解决前后端跨域问题
    rest_framework/api.html
    Vue中使用markdown
  • 原文地址:https://www.cnblogs.com/zhaopengcheng/p/6792692.html
Copyright © 2011-2022 走看看