ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Spring 的无版本模式(最新版本) > 原文: [https://howtodoinjava.com/spring-core/do-not-specify-version-numbers-in-spring-schema-references/](https://howtodoinjava.com/spring-core/do-not-specify-version-numbers-in-spring-schema-references/) 如果您从事过 Spring 框架项目,那么您必须已经看到 spring 上下文配置文件(例如`applicationContext.xml`),其中在标头中为各种 spring 模块指定了模式引用(`.xsd`)。 在模式引用中,我们提到了 xml 名称空间和模式版本号。 那么**根本不需要指定模式版本号**,您可以忽略它。 如果确实如此,您应该一直忽略它。 将其视为要遵循的[最佳实践](https://howtodoinjava.com/java-best-practices/)。 > Spring **自动从项目依赖项(jar)中选择可用的最高版本**。 另外,随着项目的发展和 Spring 版本的更新,我们不必维护所有 XML 配置文件即可看到新功能。 ## 无版本 Spring 模式示例 #### 有版本模式 `applicationContext.xml` ```java <?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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <!-- Other bean definitions--> </beans> ``` #### 无版本模式 可以这样写: `applicationContext.xml` ```java <?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"> <!-- Other bean definitions--> </beans> ``` 将我的问题放在评论部分。 学习愉快!