spring 的配置文件的beans 里面有属性头部如下:

<?xml version="1.0" encoding="UTF-8"?>
<!--suppress ALL -->
<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"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

xmlns:xxx 就是定义一个 xxx前缀命名空间。然后下面可以如此定义  <xxx:apple .../> ,当然apple 是在shema文件中声明好的。shema 文件在哪里找?就是后面的  xsi:shemaLocation 里,其里面的值是成对出现的。

key 是前头通过 xmlns:xxx 定义时的值,如上面的“http://www.springframework.org/schema/aop” ,value 是一个url地址(当然其实也可以是非url字符串),那么spring是如何读取这个url对应的shema文件的呢?spring会扫描所有的jar文件,查找 jar文件里/META-INF/ 下面的 spring.handlers 和 spring.shemas 2个文件。

spring.handlers 文件是定义 使用哪个class类来解析该段 xml内容 ,形如:

http\://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler

spring.shemas 文件里定义的是 schema文件的真实地址(基于classPath的)

http\://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd
http\://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd
http\://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd
http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.0.xsd

故,其实在断网的情况下,spring肯定也是可以正常启动的。

spring的shema文件如何读取相关推荐

  1. java中属性文件读取案例_java相关:Spring中属性文件properties的读取与使用详解

    java相关:Spring中属性文件properties的读取与使用详解 发布于 2020-6-3| 复制链接 摘记: Spring中属性文件properties的读取与使用详解实际项目中,通常将一些 ...

  2. Spring Cloud项目是如何读取bootstrap.properties文件的?

    提前说明:关于Spring Cloud和Spring Boot源码分析基于的版本如下所示 <!-- Spring Dependencies --> <dependency> & ...

  3. spring配置xml文件_XML配置文件中的Spring配置文件

    spring配置xml文件 我的上一个博客非常简单,因为它涵盖了我从Spring 3.0.x到Spring 3.1.x的轻松升级,最后我提到可以将Spring模式升级到3.1,以利用Spring的最新 ...

  4. springMVC从上传的Excel文件中读取数据

    示例:导入客户文件(Excle文件) 一.编辑customer.xlsx 二.在spring的xml文件设置上传文件大小 <!-- 上传文件拦截,设置最大上传文件大小 10M=10*1024*1 ...

  5. 原生java读取properties与spring中@value、@ConfigurationProperties读取配置文件

    原生java读取properties与spring中@value.@ConfigurationProperties读取配置文件 1.properties类 Properties 继承于 Hashtab ...

  6. SpringBoot yml文件数据读取

    读取配置数据 使用 @Value注解 使用 @Value("表达式") 注解可以从配合文件中读取数据,注解中用于读取属性名引用方式是:${一级属性名.二级属性名--} 我们可以在 ...

  7. Mr.张小白(案例:基于Spring MVC实现文件上传和下载)

    基于Spring MVC实现文件上传和下载 一.步骤 1.引入相关依赖pom.xml <?xml version="1.0" encoding="UTF-8&quo ...

  8. vc++从txt文件中读取数据

    数值分析课上老师说要将数据写在txt文件上,然后让程序从txt文件中读取数据.让本来C++已经遗忘了很久的我们无从下手,在网上也查看了很多,发现大多都是扯淡,放在VC++编辑器上发现并不能运行,不知道 ...

  9. android中XMl文件的读取

    废话不多说了直接上代码: 新建一个Xml文件用于读取: test.xml <Languages cat="1"><lan id="1"> ...

最新文章

  1. MySQL高级查询语句
  2. 【神经网络】Dependency Parsing的两种解决方案
  3. zlggui菜单12864_lcddrive.h
  4. MyEclipse中文网发布
  5. 阿尔伯塔大学的计算机科学专业好吗,阿尔伯塔大学哪个专业好?三大热门方向成就高薪未来...
  6. centos7安装samba服务器
  7. C# Winform 窗体美化(七、Win7 Aero 毛玻璃效果)
  8. Win10自带虚拟机管理器HyperV安装CentOS7
  9. linux c变量命名规则,C语言中变量名及函数名的命名规则与驼峰命名法
  10. python数字类型及运算_Python数据类型之数字(Numbers)和运算符
  11. 约瑟夫问题(猴子选大王)
  12. 22、redis中数据库默认是多少个db 及作用?
  13. Julia: Array元素过滤、元素替代、元素删除等酸爽操作
  14. taskctl跨调度服务依赖实现
  15. vi最全使用说明(转)
  16. 爬取新浪滚动新闻--每个详情页标题以及内容
  17. 电脑之间快速传输超大文件(100GB以上)的方法
  18. 怎样学习jQuery,jQuery学习教程
  19. oracle生僻字解决方案
  20. CREO3.0二次开发+VS2012环境配置

热门文章

  1. asp.net服务器之间文件,aspnet 服务器文件
  2. 推荐必读:测试人员如何快速熟悉新业务?
  3. 中文版ASAM OpenSCENARIO 1.0标准解读
  4. python程序下载腾讯企业邮箱附件_获取腾讯企业邮箱通讯录python脚本(带登录功能)...
  5. Android开发之Webview中原生与JS交互
  6. 可ping通外网,浏览器却访问不了外部网络
  7. LTE 系统信息SI
  8. 安卓手机分辨率修改工具的使用方法
  9. 好玩的Ipaddian
  10. 蚂蚁金服-微贷事业群 (北京、杭州)招前端