applicationContext.xml(Spring)

bean和aspect都通过注释的方式

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
         <!--注释方式扫描bean-->
         <context:annotation-config/>
        <!-- 对以manager开头的包进行扫描 -->
        <context:component-scan base-package="manager"/>
    <!-- 启用Spring对基于@AspectJ aspects的注释支持 -->
    <aop:aspectj-autoproxy></aop:aspectj-autoproxy>
</beans> 

bean通过xml配置,aspect通过注释

<?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:tx="http://www.springframework.org/schema/tx"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
           http://www.springframework.org/schema/context">  

    <!-- 启用Spring对基于@AspectJ aspects的注释支持 -->
    <aop:aspectj-autoproxy></aop:aspectj-autoproxy>
   <bean id="xxx"  class="xxx"></bean>
</beans>  

bean通过注释,aspect通过xml配置

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

        <!-- 通过annotation来进行bean的创建 -->
        <context:annotation-config/>
        <!-- 对以manager开头的包进行扫描 -->
        <context:component-scan base-package="manager"/>
        <!-- 通过xml方式来配置AOP -->
        <aop:config>
            <!-- 声明在哪些位置我要加入这个切面 -->
             <aop:pointcut expression="execution(* find*(..))" id="testpointcut"/>
              <!-- 声明一个切面 -->
            <aop:aspect id="AspectJAdvice" ref="aspectJAdvice">
                <aop:before method="doBefore" pointcut-ref="testpointcut"/>
                 <aop:after method="doAfter" pointcut-ref="testpointcut"/>
                  <aop:around method="doAround" pointcut-ref="testpointcut"/>
                  <!--一定要有return属性-->
                 <aop:after-returning method="doReturn" returning="retVal" pointcut-ref="testpointcut"/>
                  <!--一定要有throwing属性-->
              <aop:after-throwing throwing="ex" method="doThrowing" pointcut-ref="testpointcut"/>

            </aop:aspect>
        </aop:config>
</beans>
时间: 2024-07-31 02:39:09

applicationContext.xml(Spring)的相关文章

Delphi 操作 XML(一)

一.欢迎 本帮助文件提供从SimDesign BV的NativeXml组件的信息. 二.购买NativeXml! NativeXml现在是开源的,但支持是仅专门适用于购买NativeXml的客户. 您可以通过此链接购买NativeXml:http://www.simdesign.nl/xml.html 价格:29.95欧元 采购NativeXml的优势: 两年的通过电子邮件或特殊的"NativeXml Source"论坛支持,接收测试和修正,并从"NativeXml Sour

delphi 操作 XML (二)

在装有Win7 32位系统的台式机上 先卸载旧驱动,再重新安装. 对设备管理器里的U转串口设备从本地更新驱动,选择下图文件 系统弹出红色提示框(是否安装XXXX驱动),选择安装,随后该设备由无法启动变为工作正常. 在Win8 64位系统上 安装驱动后,出现下图情况,设备无法启动(错误代码10) 选择08年的驱动后,串口恢复正常. 总结 这些驱动有很多不兼容的,特别是在高级Windows版本或64位系统上,解决的思路就是多尝试安装各种版本,并根据串口状态调整安装策略. delphi 操作 XML

使用XPath查询带有命名空间(有xmlns)的XML(转)

使用XPath查询带有命名空间(有xmlns)的XML 标签: xmlsilverlightwebserviceencodingwpfinclude 2012-06-19 10:26 3235人阅读 评论(0) 收藏 举报  分类: XML(7)  最近碰到一个小问题,通过调用webservice返回如下的xml, <Seller xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http:

Android 创建与解析XML(五)—— Dom4j方式

分享一下我老师大神的人工智能教程吧.零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net 1.Dom4j概述 dom4j is an easy to use, open source library for working with XML, XPath and XSLT on the Java platform using the Java Collections Framework and with full sup

spring bean 加载过程(spring)

以classpathXmlApplication为例 入口方法包含3个部分, public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh, ApplicationContext parent) throws BeansException { super(parent); setConfigLocations(configLocations); if (refresh) { refresh(); }

java web开发入门四(spring)基于intellig idea

spring 1.spring简介 Spring框架,可以解决对象创建以及对象之间依赖关系的一种框架. 且可以和其他框架一起使用:Spring与Struts,  Spring与hibernate (起到整合(粘合)作用的一个框架) Spring提供了一站式解决方案: 1) Spring Core  spring的核心功能: IOC容器, 解决对象创建及依赖关系 2) Spring Web  Spring对web模块的支持. -à 可以与struts整合,让struts的action创建交给spr

5、XML(1)

1 XML入门 1.1 引入 HTML: 负责网页的结构 CSS: 负责网页的样式(美观) Javascript: 负责在浏览器端与用户进行交互. 负责静态的网页制作的语言 HTML语言特点: 1)由标签组成. <title> <p> <hr/> <br/> 2)语法结构松散的    <p></p>   <p>  <P> 大小写不区分 结束标签和开始标签不一定匹配 <html> <head&g

XML(一)XML大揭秘

前言 每天都要学习很多新的知识,比你厉害的程序员比你还努力,那你混的下这口饭吗?所以不抱怨,坚持!接下来给大家分享的是xml.可能很多做开发的都遇到过xml, 比如maven,各种框架的配置文件都有,但是你有没有深入的去了解一下xml呢?xml是可扩展标记语言,标准通用标记语言的子集,是一种用于标记电子文件使其具有结构性的标记语言. 一.XML简介 1.1.XML简单的历史介绍 1969年 GML (General Markup Language,通用标记语言): 用于计算机之间的通信,通信就会

spring boot(spring)

一:spring的介绍 Spring是一个开源框架,它由Rod Johnson创建.它是为了解决企业应用开发的复杂性而创建的. 它是一个容器框架,用来装javabean(java对象),中间层框架(万能胶)可以起一个连接作用,比如说把Struts和hibernate粘合在一起运用.简单来说,Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架. 二:spring boot 1. Spring Boot简介Spring 诞生时是 Java 企业版(Java Enterpris