关于applicationContext.xml文件中的一些标签及详解

<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"
    xmlns:context="http://www.springframework.org/schema/context"
    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.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-2.5.xsd">

beans  是xml文件的根节点

xmlns  XML NameSpace的缩写,用以区分这个xml文件不同于其余的xml

xmlns:xsi   XML Schema instance namespace  指定了xml所使用的Schema(模式)定义的语言及需要遵循的规范

xmlns:aop  使用spring框架的aop 面向切面编程时,在xml文件中引入aop资源

xmlns:tx  spring 事务配置

xsi:schemaLocation  引入所有xml本文档需要遵循的规范   解析器在需要的情况下对该属性引入的文档进行校验,他引入的文档以成对的形式出现,第一个值表示命名空间,第二个值表示该命名空间的模式文档的具体位置,两个值之间以空格分割

 <bean id="A" class="com.baidu.asd.sys.Awesdf"
        lazy-init="false" />

框架之间可以整合使用,当其他框架和spring框架进行整合使用时,一般可以把对类的创建管理任务交给spring,在spring中给某个类定义一个别名,当其他框架例如strus需要使用该类时,可以直接使用 A 而不是写类全名,将对象的权利交给spring,(当然struts也可以写类全名,这样的话就是他自己进行类管理创建了,不利于整个项目的管里)

<property name="   " value="   " />

可以对数据连接等相关信息进行配置 name

猜你喜欢

转载自blog.csdn.net/FXMDLF/article/details/81206403