spring中的命名空间
2015-06-09 15:34
471 查看
一、IoC 概述
IoC(控制反转:Inverse of Control)是Spring 容器的核心,与DI(依赖注入:Dependency Injection)是同一个意思。
从注入方法上看,主要可以划分为三种类型:构造函数注入、属性注入和接口注入。Spring 支持构造函数注入和属性注入。
构造函数注入
在构造函数注入中,我们通过调用类的构造函数,将接口实现类通过构造函数变量传入。由于是构造函数,就必须注入,没有选择性。
属性注入
属性注入可以有选择地通过Setter 方法完成调用类所需依赖的注入,更加灵活方便。
接口注入
将调用类所有依赖注入的方法抽取到一个接口中,调用类通过实现该接口提供相应的
注入方法。为了采取接口注入的方式,必须先声明一个接口,由于通过接口注入需要额外声明一个接口,增加了类的数目,而且它的效果和属性注
入并无本质区别。
二、Spring 3的命名空间
可以访问:http://www.springframework.org/schema/
查看所有的schema文件,和对应的命名空间。
常用的命名空间如下:
spring-beans-3.0.xsd 最主要的命名空间,也是默认命名空间,用于配置Bean。
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
简化属性配置
p命名空间,设置属性值的格式为 p:属性名="值"
http://www.springframework.org/schema/p
(由于属性名是可变的,所以没有对应的Schema文件)
spring-tx-3.1.xsd 声明式事务配置
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
spring-context-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
spring-mvc-3.0.xsd Spring MVC的配置
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
spring-aop-3.0.xsd AOP的配置
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
spring-util-3.1.xsd 简化某些复杂的标准配置
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
spring-jdbc-3.1.xsd Spring内嵌数据库的配置
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
spring-jee-3.1.xsd 为了简化EJB,JDNI提供的
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
spring-jpa.xsd jpa配置
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
spring-jms-3.0.xsd JMS配置
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
spring-lang-3.0.xsd JRuby,Groovy动态语言配置
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
spring-oxm-3.0.xsd 配置对象XML映射
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
spring-task-3.0.xsd 任务调度
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
spring-tool-3.0.xsd 可集成Spring一些有用的工具
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
IoC(控制反转:Inverse of Control)是Spring 容器的核心,与DI(依赖注入:Dependency Injection)是同一个意思。
从注入方法上看,主要可以划分为三种类型:构造函数注入、属性注入和接口注入。Spring 支持构造函数注入和属性注入。
构造函数注入
在构造函数注入中,我们通过调用类的构造函数,将接口实现类通过构造函数变量传入。由于是构造函数,就必须注入,没有选择性。
属性注入
属性注入可以有选择地通过Setter 方法完成调用类所需依赖的注入,更加灵活方便。
接口注入
将调用类所有依赖注入的方法抽取到一个接口中,调用类通过实现该接口提供相应的
注入方法。为了采取接口注入的方式,必须先声明一个接口,由于通过接口注入需要额外声明一个接口,增加了类的数目,而且它的效果和属性注
入并无本质区别。
二、Spring 3的命名空间
可以访问:http://www.springframework.org/schema/
查看所有的schema文件,和对应的命名空间。
常用的命名空间如下:
spring-beans-3.0.xsd 最主要的命名空间,也是默认命名空间,用于配置Bean。
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
简化属性配置
p命名空间,设置属性值的格式为 p:属性名="值"
http://www.springframework.org/schema/p
(由于属性名是可变的,所以没有对应的Schema文件)
spring-tx-3.1.xsd 声明式事务配置
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
spring-context-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
spring-mvc-3.0.xsd Spring MVC的配置
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
spring-aop-3.0.xsd AOP的配置
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
spring-util-3.1.xsd 简化某些复杂的标准配置
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
spring-jdbc-3.1.xsd Spring内嵌数据库的配置
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
spring-jee-3.1.xsd 为了简化EJB,JDNI提供的
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
spring-jpa.xsd jpa配置
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
spring-jms-3.0.xsd JMS配置
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
spring-lang-3.0.xsd JRuby,Groovy动态语言配置
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
spring-oxm-3.0.xsd 配置对象XML映射
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
spring-task-3.0.xsd 任务调度
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
spring-tool-3.0.xsd 可集成Spring一些有用的工具
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
相关文章推荐
- Ubuntu配置eclipse
- Spring常用注解,自动扫描bean
- maven+springMVC+mybatis+junit详细搭建过程
- SpringMVC整合fastjson-1.1.41
- spring使用注解实现AOP
- 杭电ACM2023java做法
- spring的编程式事务、XML配置事务、注解实现事务
- Mybatis学习(5)与spring3集成
- spring的数据源配置DBCP,C3PO,BoneCP
- 如果debug 启动spring 时跳到concurrentHashMap中……
- Spring Bean的5种作用域
- java 中有几种类型的流?JDK 为每种类型的流提供了一些抽象类以供继承, 请说出他们分别是哪些类?
- Ubuntu系统下安装Myeclipse10.6
- java 线程池
- 什么是 java 序列化,如何实现 java 序列化?
- Java文件操作大全(转载的)
- Spring -- framework 各版本源码下载地址
- Spring -- framework 各版本源码下载地址
- Spring -- framework 各版本源码下载地址
- java 线程中 stop()和 suspend()方法为何不推荐使用?