好记性不如烂笔头88-spring3学习(9)-schema的配置的解读和说明
Spring1使用了DTD格式,spring2以后使用的是schema的格式;使用schema的格式,支持了不同类型的配置拥有了自己的命名空间,让配置文件有了更加好的扩展性。
不论什么事情,都是有利有弊,使用了schema格式,bean.xml的文件头的声明就会相对复杂非常多,每当我看到这些复杂的东东,我就觉的头的复杂了起来。
如《弟子规》所言,“功夫到 滞塞通”,这些东西,在实际工作中重复看,用心学,总能体会和了解的。
常见的spring配置说明
一个在简单项目中的完整bean.xml文件
<?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"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
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.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<bean id="role1" class="com.spring.Role"
p:name="范芳铭"
p:type="admin" />
<aop:config>
<aop:advisor pointcut=”execution(* *..facade.*(..))” advice-ref=”txAdvice” />
</aop:config>
</beans>
- 1、 默认命名空间
http://www.springframework.org/schema/beans
它没有空间名称,用于Spring Bean的定义;
- 2、 Xsi标准命名空间
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
这个命名空间为每一个文档中命名空间指定相应的schema样式,是标准组织定义的标准命名空间;
- 3、 自己定义命名空间
xmlns:aop=”http://www.springframework.org/schema/aop”
aop是该命名空间的简称
“http://www.springframework.org/schema/aop” 是该命名空间的全程,必须在xsi命名中间为它指定相应的schema文件。
这个命名空间分2步,一个是定义命名空间的名称(比方aop),然后指定命名空间样式文档的位置。
- 4、 命名空间相应的schema文件
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
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd"
5、 默认命名空间配置
<bean id="role1" class="com.spring.Role"
- 6、 aop命名空间配置
<aop:config>
<aop:advisor pointcut=”execution(* *..facade.*(..))” advice-ref=”txAdvice” />
好记性不如烂笔头88-spring3学习(9)-schema的配置的解读和说明的更多相关文章
- 好记性不如烂笔头-linux学习笔记1
好记性不如烂笔头-linux学习笔记1 linux的文件系统有ext2,ext3,ext4,目前主流是ext4 linux主要用于服务器级别的操作系统,安装时需要至少2个分区 一个是交换分区,swap ...
- 好记性不如烂笔头-Mysql查找如何判断字段是否包含某个字符串
好记性不如烂笔头-Mysql查找如何判断字段是否包含某个字符串 利用mysql 字符串函数 find_in_set(); SELECT * FROM users WHERE find_in_set(' ...
- [nodejs]修改全局包位置,修复npm安装全局模块命令失效。好记性不如烂笔头
修复npm -g 全局安装命令失效,好的吧不得不承认,好记性不如烂笔头,我居然会忘记方法哈哈哈 Linux安装nodejs sudo apt install node sudo apt install ...
- Common lang一些边界方法总结(好记性不如烂笔头,需要慢慢积累).一定要利用好现有的轮子,例如Apache common与Google Guava
好记性真是不如烂笔头啊!!!! 如下代码: List<String> list = new ArrayList<String>(); list.add("1" ...
- 好记性不如烂笔头85-spring3学习(6)-BeanFactory 于bean生命周期
假设BeanFactory为了产生.管理Bean, 一个Bean从成立到毁灭.它会经过几个阶段运行. 据我所知,一般bean包括在生命周期:设定,初始化,使用阶段,四个核心阶段销毁. 1.@Bean的 ...
- 好记性不如烂笔头-linux学习笔记2kickstart自动化安装和cacti
kickstart自动化安装的逻辑梳理 主要是安装tftp nfs dhcp 然后配置kickstart 原来就是先安装tftp 可实现不同机器的文件下载 然后在安装nfs 就是主服务器的文件系统 然 ...
- 好记性不如烂笔头--linux学习笔记9练手写个shell脚本
#!/bin/bash #auto make install httpd #by authors baker95935 #httpd define path variable H_FILES=http ...
- 好记性不如烂笔头--linux学习笔记8关于nginx的动静分离
动静分离逻辑梳理 就是给nginx配置访问规则,不同后缀的文件访问不同的目录 worker_processes 1; events { worker_connections 1024; } http ...
- 好记性不如烂笔头-linux学习笔记6keepalived实现主备操作
Keepalived的作用是检测服务器的状态,如果有一台web服务器宕机,或工作出现故障,Keepalived将检测到,并将有故障的服务器从系统中剔除,同时使用其他服务器代替该服务器的工作,当服务器工 ...
随机推荐
- Perl遍历查找文件
Perl遍历查找文件 使用Perl查找当前目录下的所有PDF文件 ******************************************************************* ...
- [AngularJS Ng-redux] Integrate ngRedux
Up to this point, we have created an effective, yet rudimentary, implementation of Redux by manually ...
- icvPrecalculate
/* *icvPrecalculate *作用:计算特征值,并排序 *详细来说也就是依据训练样本信息和haar特征信息,在函数内部引用icvGetTrainingDataCallback来 *分批计算 ...
- Android自定义组件系列【10】——随ViewPager滑动的导航条
昨天在用到ViewPager实现滑动导航的时候发现微信的导航条效果是跟随ViewPager的滑动而动的,刚开始想了一下,感觉可以使用动画实现,但是这个滑动是随手指时时变化的,貌似不可行,后来再网上搜了 ...
- jquery画图插件jPainter
jquery画图插件jPainter 一.总结 一句话总结:四年前的项目,四年无更新,不好用. 二.基于HTML5 Canvas和jQuery 的画图工具的实现 简介 HTML5 提供了强大的Canv ...
- yield return
一次被yield return坑的历程. 事情的经过是这样的: 我用C#写了一个很简单的一个通过迭代生成序列的函数. public static IEnumerable<T> Iter ...
- [SCSS] Reuse Styles with the SCSS @extend Directive
We can write reusable styles with the SCSS @extend or @mixin directives. Which one is better? It dep ...
- [Grid Layout] Specify a grid gutter size with grid-gap
It’s beautifully straightforward to add a gutter to our grid layout. Let’s apply one with grid-gap.
- php实现 提取不重复的整数(编程题目能够最快的熟悉函数)
php实现 提取不重复的整数(编程题目能够最快的熟悉函数) 一.总结 一句话总结:编程题目能够最快的熟悉函数. 1.字符串反转函数? 没有str_revserse,有arr_reverse,这里是st ...
- 简洁常用权限系统的设计与实现(六):不维护节点的深度level,手动计算level,构造树 (把一颗无序的树,变成有序的)
本篇介绍的方法,参考了网上的代码.在递归过程中,计算level,是受到了这种方法的启发. CSDN上有篇关于树的算法,目标是把一个无序的树,变成有序的. 我看了下代码,并运行了下,感觉是可行的. 我 ...