我是春天的新来者。有一件事让我感到困惑,有时我看到 XML 配置文件带有版本化的模式,但有时又带有非版本化的模式。比如,有时候我看到
<?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">
<context:annotation-config/>
<context:component-scan base-package="base.package"/>
</beans>
有时像这样:
<?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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<context:component-scan base-package="base.package"/>
</beans>
请注意,在这两个示例中,spring-beans和 spring-context模式是不同的。
所以,我的问题是,你会用哪种风格,为什么?特别是,版本化的模式将来是否不可用,以及当 Spring 更新模式时,非版本化的模式是否与当前应用程序保持兼容?
另一个问题是,我在哪里可以找到版本化的 Spring 模式列表?