Spring启动时加载xml文件的过程:

spring在加载xsd文件时总是先试图在本地查找xsd文件(spring的jar包中已经包含了所有版本的xsd文件),如果没有找到,才会转向去URL指定的路径下载。

在很多spring的jar包里,在META-INF目录下都有一个spring.schemas,这是一个property文件,其内容类似于下面:

http\://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
....

实际上,这个文件就是spring关于xsd文件在本地存放路径的映射,spring就是通过这个文件在本地(也就是spring的jar里)查找xsd文件的。

那么,查找不到的原因排除URL输入有误之外,可能就是声明的xsd文件版本在本地不存在。一般来说,新版本的spring jar包会将过去所有

版本(应该是自2.0以后)的xsd打包,并在spring.schemas文件中加入了对应项,出现问题的情况往往是声明使用了一个高版本的xsd文件,

如3.0,但依赖的spring的jar包却是2.5之前的版本,由于2.5版本自然不可能包含3.0的xsd文件,此时就会导致spring去站点下载目标xsd文件,

如遇断网或是目标站点不可用,上述问题就发生了。

可以将文件中的版本号去掉,直接去找默认的文件:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">

最新文章

  1. JMeter学习-007-JMeter 断言实例之一 - 响应断言
  2. rediscluster 集群操作(摘抄)
  3. mybatis处理集合、循环、数组和in查询等语句的使用
  4. PAT1015. Reversible Primes
  5. static public和 public static 区别
  6. [LeetCode]LRU Cache有个问题,求大神解答【已解决】
  7. Day07 - Python 网络编程 Socket
  8. 下载网易云VIP音乐
  9. Day4 《机器学习》第四章学习笔记
  10. SSH的软链接后门
  11. Swift ios应用开发实践
  12. python循环语句详细讲解
  13. contourf和contour用法区别
  14. 通用Mapper
  15. 【域名配置】Tomcat外网发布域名配置
  16. OK335xS canutils deal with compile error
  17. 第5章 进程环境(1)_进程结构(task_struct)
  18. [SoapUI] 设置最大等待时间,不断重复的去发送一个request,每次从response中获取一个status,直到这个status从一种状态变成另外一种状态
  19. 使用类加载器加载配置文件/getClassLoader().getResourceAsStream()
  20. python中的编解码小结

热门文章

  1. ffmpeg把ts文件转m3u8并切片
  2. node.js--Less
  3. 【Oracle】两个表Join关联更新
  4. 彻底删除weblogic域方法
  5. Unity透明Shader
  6. DexArchiveBuilderException
  7. GLIBC_2.14报错
  8. 从经典问题来看 Copy 方法
  9. ECMAScript 面向对象JS学习笔记1
  10. QT——信号槽