Spring配置文件命名空间
2013-12-04 10:04
337 查看
xmlns
是xml namespace的缩写,也就是XML命名空间,xmlns 属性可以在文档中定义一个或多个可供选择的命名空间
<?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" 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.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <aop:aspectj-autoproxy/> <!--使用注解的方式AOP注入--> <bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"/> <bean id="person" class="hb.dao.imp.PersonImp"/> <bean id="aop" class="hb.aop.Aop"/> </beans>
命名空间的内容可以从对应的jar包中找到,这里以AOP为例子说明,如图
打开spring.schemas文件,可以查看到对应命名空间内容,然后输入到配置文件中(这里要保证版本对应)
http\://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd http\://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.5.xsd
在配置文件中的xsi:schemaLocation标签的内容有顺序,例如
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
必须保证http://www.springframework.org/schema/aop
在 http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
前面,否则不会正确的解析
相关文章推荐
- 【spring】配置文件命名空间写法
- Spring学习1--配置文件的命名空间
- 【spring】spring配置文件命名空间(如:xmlns:beans="http://www.springframework.org/schema/beans")
- eclipse中配置Spring配置文件自动提示和命名空间
- spring---------配置文件的命名空间
- spring 配置文件上面的命名空间和规范复习
- Spring配置文件的命名空间URI
- eclipse中spring配置文件的自动提示和命名空间的添加
- spring 配置文件 常使用的命名空间
- [原]eclipse中spring配置文件的自动提示和命名空间的添加
- spring---------配置文件的命名空间
- eclipse中spring配置文件的自动提示和命名空间的添加
- Spring配置文件之引入命名空间
- eclipse中spring配置文件的自动提示和命名空间的添加
- 在Spring的XML文件中通过命名空间配置的标签是怎么解析的?
- eclipse中spring配置文件的自动提示和命名空间的添加
- spring的xml配置文件中命名空间
- SPRING---------配置文件的命名空间
- spring配置文件命名空间读取顺序
- spring配置文件 --可恶的命名空间