Spring 学习手册

1: 登陆官网 http://spring.io/
   1) 点击Docs
   2) 选择Springframework
   3) 选择“refrence”
    4)  选择33. XML Schema-based configuration
2:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi: schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!-- bean definitions here -->

</beans>
The 'xsi:schemaLocation' fragment is not actually required, but can be included to reference a local copy of a schema (which can be useful during development).
这句话的意思是'xsi:schemaLocation' 此标签不是一定要求的,我们可以参考已有开发系统的框架命名。
当前的版本为4.0.6那么我们就参考原来的3.2的版本,修改此处为
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
在此我添加了spring的2个shema,beans和context,并且带上了版本号。
请注意当前的版本为4.0.6,http://www.springframework.org/schema/context/spring-context-4.0.xsd
而我确填写的为4.0,这里我猜想是spring这里只允许填4.0是因为版本会有后续的改动,下一个版本可能会是4.0.7,那么每次升级一个版本这个schema就要变,这样很冗余,所以此处的4.0就代表当前4.0.0--4.0.7的所有。
如何验证呢?当我们点击http://www.springframework.org/schema/context/spring-context-4.0.xsd能正确的指到一个页面而不报404,那么就说这个是可用的

猜你喜欢

转载自neebe.iteye.com/blog/2097507