<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.1.xsd">

  使用spring已经好几年了,但是每次遇到要自己配置spring项目时就头疼,通过网络各种复制别人的配置文件,然后一不小心就报错了,所以今天想探探究竟。

  如上是一个spring-context配置文件

xmlns部分:

1.

xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  这个是每个配置文件必须的部分,也就是spring的根本。

  声明xml文件默认的命名空间,表示未使用其他命名空间的所有标签的默认命名空间。

  声明XML Schema 实例,声明后就可以使用 schemaLocation 属性了。

2.

xmlns:aop="http://www.springframework.org/schema/aop"

  这个就是spring配置文件里面需要使用到aop的标签,声明前缀为aop的命名空间,后面的URL用于标示命名空间的地址不会被解析器用于查找信息。其惟一的作用是赋予命名空间一个惟一的名称。当命名空间被定义在元素的开始标签中时,所有带有相同前缀的子元素都会与同一个命名空间相关联。然后其他比如context(针对组件标签)、MVC(针对mvc标签)、tx(针对事务标签)都一样的意思。

xsi:schemaLaction部分:

1.

http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

是为上面配置的命名空间指定xsd规范文件,这样你在进行下面具体配置的时候就会根据这些xsd规范文件给出相应的提示,比如说每个标签是怎么写的,都有些什么属性是都可以智能提示的,以防配置中出错而不太容易排查,在启动服务的时候也会根据xsd规范对配置进行校验。但是这里需要为你上面xmlns里面配置的mvc、aop、tx等都配置上xsd规范文件。

最新文章

  1. 关于本月第一天,本月最后一天的SQL代码
  2. css中的1px并不总等于设备的1px(高分辨率不等 低分辨等)
  3. C#与Swift异步操作的差异
  4. dubbo源码学习(一)之ExtensionLoader
  5. plupload+struts2实现文件上传下载
  6. Android——C语言、JNI与低层调用
  7. Duanxx的C++学习 : 数字转换String
  8. xss框架的一些想法
  9. DataFrame操作方式
  10. BZOJ 1856: [Scoi2010]字符串 [Catalan数]
  11. directdraw显示yuv420(YV12)
  12. SWFUpload文件上传详解
  13. Hibernate--对象关系
  14. Oracle12c中分区(Partition)新特性之TRUNCATEPARTITION和EXCHANGE PARTITION级联功能
  15. keras使用
  16. Python学习笔记(一):Python代码的打包与发布
  17. [转]Oracle left join \ right join
  18. 查看tomcat项目中,具体占用cpu高的线程。
  19. 来了解一下Ajax是什么?Ajax的原理?Ajax与传统Web比较?Ajax的优缺点?Ajax的Post与Get比较
  20. 旋转木马幻灯片切换效果JS源码详解

热门文章

  1. lpc1788IO口模拟IIC
  2. linux pci 协议一
  3. IOS开发-OC学习-常用功能代码片段整理
  4. bzoj-4318 OSU! 【数学期望】
  5. Memcached源码分析之slabs.c
  6. RFID射频卡超市购物结算系统
  7. 交换Ctrl和Caps Lock键
  8. 微信小程序之----video视频播放
  9. JAVA-Unit01: 数据库原理 、 SQL(DDL、DML)
  10. bzoj1396