相关疑难解决方法(0)

Spring配置XML模式:有没有版本?

我是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>
Run Code Online (Sandbox Code Playgroud)

有时像这样:

<?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>
Run Code Online (Sandbox Code Playgroud)

请注意,两个示例中的spring-beansspring-context模式不同.

所以,我的问题是,你会使用哪种风格?为什么?特别是,版本化架构将来是否会变得不可用,并且当Spring更新架构时,非版本化架构是否会与当前应用程序保持兼容?

一个附带问题是,我在哪里可以找到版本化的弹簧模式列表?

非常感谢!

java spring

66
推荐指数
1
解决办法
6万
查看次数

标签 统计

java ×1

spring ×1