【发布时间】:2014-01-20 14:15:52
【问题描述】:
我是 Spring 新手。让我感到困惑的一件事是,有时我会看到带有版本化模式的 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 模式列表?
非常感谢!
【问题讨论】: