好记性不如烂笔头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将检测到,并将有故障的服务器从系统中剔除,同时使用其他服务器代替该服务器的工作,当服务器工 ...
随机推荐
- 【u243】拓扑排序
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 一些历史迷们打算把历史上的一些大事件按时间顺序列出来.但是,由于资料不全,每个事件发生的具体时间都没有 ...
- 简单的Java多线程的使用
前几天做一个功能.就是在前台更改信息后会自己主动发邮件给其它的人,相关信息已更改,刚開始是直接在更改信息代码后面增加发送邮件的代码,但发现这样会使界面特别慢,而慢的主要原因是因为发送邮件有时会耗时非常 ...
- Windows Server 2012 R2 部署 Exchange 2013
我的环境在DC上 ,一般建议Exchange 增加DC 通过管理员权限执行PowerShell 来安装一些IIS组件, 安装命令例如以下: Install-WindowsFeature AS-HTTP ...
- 学习Numpy
1.什么是numpy NumPy系统是Python的一种开源的数值计算扩展.这种工具可用来存储和处理大型矩阵,比Python自身的嵌套列表(nested list structure)结构要高效的多( ...
- [React Unit Testing] React unit testing demo
import React from 'react' const Release = React.createClass({ render() { const { title, artist, outO ...
- css画电脑键盘
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- [Postgre] Insert Data into Postgre Tables
// Insert one row INSERT INTO movies (title, release_date, count_stars, director_id) VALUES ( 'Kill ...
- 【矩阵】概念的理解 —— span、基
span:全部列向量的线性组合构成的集合: span[a1,-,an]={y∈Rm|y=∑k=1nckak}=S 注:ak∈Rm,共 n 个列向量: 集合 S 可以有不同的一组基,但是基中向量的个数是 ...
- [SVG] Combine Multiple SVGs into an SVG Sprite
In this lesson, we’ll explore the process of combining all of your SVG icons into one SVG sprite, to ...
- TensorFlow 辨异 —— tf.add(a, b) 与 a+b(tf.assign 与 =)、tf.nn.bias_add 与 tf.add
1. tf.add(a, b) 与 a+b 在神经网络前向传播的过程中,经常可见如下两种形式的代码: tf.add(tf.matmul(x, w), b) tf.matmul(x, w) + b 简而 ...