读书人

Spring配备文的命名空间

发布时间: 2012-09-22 21:54:54 作者: rapoo

Spring配置文的命名空间

<?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.xsd http://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 style="vertical-align: baseline;" width="232" src="/img/2012/09/14/1337221104.jpg" height="379">

?

打开spring.schemas文件,可以查看到对应命名空间内容,然后输入到配置文件中(这里要保证版本对应)

?

http\://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsdhttp\://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsdhttp\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.5.xsd

?

在配置文件中的xsi:schemaLocation标签的内容有顺序,例如

?

?

http://www.springframework.org/schema/aophttp://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
前面,否则不会正确的解析

读书人网 >开源软件

热点推荐