Spring视频学习笔记(3)Bean的作用域及自动装配
2009-05-25 20:50
746 查看
spring Bean的作用域:
scope可以取值:
* singleton:每次调用getBean的时候返回相同的实例
* prototype:每次调用getBean的时候返回不同的实例
根据名称自动装配
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-autowire="byName"
>
不适合实施阶段
根据类型自动装配
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-autowire="byType"
>
scope可以取值:
* singleton:每次调用getBean的时候返回相同的实例
* prototype:每次调用getBean的时候返回不同的实例
根据名称自动装配
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-autowire="byName"
>
不适合实施阶段
根据类型自动装配
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-autowire="byType"
>
相关文章推荐
- [原创]java WEB学习笔记99:Spring学习---Spring Bean配置:自动装配,配置bean之间的关系(继承/依赖),bean的作用域(singleton,prototype,web环境作用域),使用外部属性文件
- Spring 学习笔记(五)—— Bean之间的关系、作用域、自动装配
- Spring学习笔记(8.Spring Bean装配之自动装配)
- ITCAST视频-Spring学习笔记(@Autowire注解与自动装配)
- [Spring]Bean的自动装配Autowire【学习笔记】
- Spring学习笔记--自动装配Bean属性
- ITCAST视频-Spring学习笔记(配置Spring管理的bean的作用域)
- Spring4学习笔记(五):Bean的自动装配
- spring学习笔记(4)——配置文件配置bean自动装配
- Spring 学习笔记【一】自动装配bean
- ITCAST视频-Spring学习笔记(让Spring自动扫描和管理Bean)
- 【Spring学习笔记四】-自动装配Bean
- JavaWeb学习笔记之Spring中bean的作用域
- Spring学习笔记之Bean的作用域
- Spring学习笔记(五) --- 装配Bean之导入和混合配置
- JavaEE_SSH_Spring学习笔记(9)----让Spring自动扫描和管理Bean
- Spring 4.0 学习日记(5) ---bean的自动装配
- Spring学习----------Spring自动装配Bean的属性
- Spring in Action 学习笔记—第二章装配Bean
- ITCAST视频-Spring学习笔记(编码剖析Spring管理Bean的原理)