Spring4.0的Schema文件
spring xml配置文件头命名空间 xsd文件配置
Schema文件 | 说明 |
---|---|
spring-beans-4.0.xsd | [说明]:Spring4.0最主要的Schema,用于配置Bean [命名空间]:http://www.springframework.org/schema/beans [Schema文件]:http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
spring-aop-4.0.xsd | [说明]:AOP的配置定义的Schema [命名空间]:http://www.springframework.org/schema/aop [Schema文件]:http://www.springframework.org/schema/aop/spring-aop-4.0.xsd |
spring-tx-4.0.xsd | [说明]:声明式事务配置定义的Schema [命名空间]:http://www.springframework.org/schema/tx [Schema文件]:http://www.springframework.org/schema/tx/spring-tx-4.0.xsd |
spring-mvc-4.0.xsd | [说明]:MVC配置的Schema,是Spring3.0新增的 [命名空间]:http://www.springframework.org/schema/mvc [Schema文件]:http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd |
spring-util-4.0.xsd | [说明]:为简化某些复杂的标准配置提供的Schema [命名空间]:http://www.springframework.org/schema/util [Schema文件]:http://www.springframework.org/schema/util/spring-util-4.0.xsd |
spring-jee-4.0.xsd | [说明]:为简化JavaEE中EJB、JNDI等功能的配置而提供的Schema [命名空间]:http://www.springframework.org/schema/jee [Schema文件]:http://www.springframework.org/schema/jee/spring-jee-4.0.xsd |
spring-jdbc-4.0.xsd | [说明]:为配置Spring内嵌数据库提供的Schema,是Spring3.0新增的 [命名空间]:http://www.springframework.org/schema/jdbc [Schema文件]:http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd |
spring-jms-4.0.xsd | [说明]:JMS配置的Schema [命名空间]:http://www.springframework.org/schema/jms [Schema文件]:http://www.springframework.org/schema/jms/spring-jms-4.0.xsd |
spring-lang-4.0.xsd | [说明]:增加了对JRuby和Grooy等动态语言的支持,该Schema是为集成动态语言而定义的 [命名空间]:http://www.springframework.org/schema/lang [Schema文件]:http://www.springframework.org/schema/lang/spring-lang-4.0.xsd |
spring-oxm-4.0.xsd | [说明]:配置对象XML映射的Scheme,是Spring3.0新增的 [命名空间]:http://www.springframework.org/schema/oxm [Schema文件]:http://www.springframework.org/schema/oxm/spring-oxm-4.0.xsd |
spring-task-4.0.xsd | [说明]:任务调度的Schema [命名空间]:http://www.springframework.org/schema/task [Schema文件]:http://www.springframework.org/schema/task/spring-task-4.0.xsd |
spring-tool-4.0.xsd | [说明]:为集成Spring的一些有用工具定义的Schema [命名空间]:http://www.springframework.org/schema/tool [Schema文件]:http://www.springframework.org/schema/tool/spring-tool-4.0.xsd |
示例:
<?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.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
</beans>
xmlns=“http://www.springframework.org/schema/beans” ;
默认命名空间
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi标准命名空间,用于指定自定义命名空间的Schema文件
xmlns:aop=“http://www.springframework.org/schema/aop”
自定义命名空间
aop是该命名空间的简称
http://www.springframework.org/schema/aop 命名空间的全称,必须在xsi命名空间为其指定空间对应的Schema文件
xsi:schemaLocation="…"
为每个命名空间指定具体的Schema文件
语法为:
<命名空间1>——<命名空间1Schema文件>——<命名空间2>——<命名空间2Schema文件>
——代表空格或回车分隔符
命名空间一般写全称,Schema文件就是 .xsd文件