博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring命名空间解析
阅读量:7043 次
发布时间:2019-06-28

本文共 1165 字,大约阅读时间需要 3 分钟。

spring 整合了各种工具,并且spring提供了对各种工具的xml scheme 的配置方式,简化了开发。

首先

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

是必须存在的,可以从spring的文档和例子中查找到,

xsi:schemaLocation 指定了用于解析和校验xml的定义文件(xsd)的位置。
我们以添加aop命名空间为例:
在spring.jar文件中的META—INF目录中提供了spring.schemas 文件,这个文件指定了提供支持的功能的xml元素配置的命名空间定义文件的位置,在这个文件中我们可以找到aop的位置:

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.xsd=org/springframework/aop/config/spring-aop-2.5.xsd

那么我们可以在spring.jar文件的对应目录中找到这些xsd文件,打开文件以后,

可以看到标签:

那么第一个xmlns就是要引进的命名空间,但是在引进applicationContext.xml之前需要修改为:

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

之后添加入applicationContext.xml文件中,且一定要放置于xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"之后,顺序不能错。

之后需要在xsi:schemaLocation 中添加位置:

http://www.springframework.org/schema/aop(空格)http://www.springframework.org/schema/aop/spring-aop-2.5.xsd

而/spring-aop-2.5.xsd就是aop的元素的定义的文件名

转自:

转载地址:http://flhal.baihongyu.com/

你可能感兴趣的文章
nginx的日志分析
查看>>
ListView原理
查看>>
python--------------内置函数
查看>>
Scapy基础学习之中的一个
查看>>
http请求头详解
查看>>
SVNserver搭建
查看>>
Java基础(九):抽象类
查看>>
Unix:关于一个file在file system和disk中占用空间
查看>>
duilib 的IE浏览器控件去边框和去滚动栏的代码
查看>>
.NET平台微服务项目汇集
查看>>
线段树
查看>>
[CSS] Build a Fluid Loading Animation in CSS
查看>>
UWP开发入门(八)——聊天窗口和ItemTemplateSelector
查看>>
Java线程之Callable和Future
查看>>
多线程的实现及常用方法_DAY23
查看>>
在访问RESTful接口时出现:Could not write content: No serializer found for class的问题解决小技巧收集...
查看>>
linux下vim命令详解
查看>>
[AngularFire] Firebase OAuth Login With Custom Firestore User Data
查看>>
c++11 nullptr
查看>>
SpringMVC系列(二): SpringMVC各个注解的使用
查看>>