Spring--IOC
来源:互联网 发布:matlab矩阵求转置 编辑:程序博客网 时间:2024/06/06 03:39
1、Spring 生命周期Scope
<bean id="" class="" scope=“”></bean>
singleton (默认) 单例模式
prototype 每次取都是新的
以下三种与web使用
request
session
globalsession
2、集合注入
<bean id="" class="" >
<property name="">相当于调用set方法
<props>
<prop key="">...</prop>
<prop key="">...</prop>
<prop key="">...</prop>
</props>
</property>
</bean>
<bean id="" class="" >
<property name="">相当于调用set方法
<list>
<value>...</value>
<ref bean=""/>
</list>
</property>
</bean>
<bean id="" class="" >
<property name="">相当于调用set方法
<map>
<entry>
<key>
<value>...</value>
</key>
<value>....</value>
</entry>
<entry>
<key>
<value>...</value>
</key>
<value>....</value>
</entry>
</map>
</property>
</bean>
3、自动装配 Autowire
<bean id="" class="" scope=“” autowire=""></bean>
byType 按照类型自动匹配
default
4、注解
<context:annotation-config /> 初始化4个bean
@Autowired 对应类型的自动注入(默认byType) 位于setter方法上面 如果有两个一样的类型的beanid 可用@Qualifier(“beanID”)指定是哪个
@Resource 位于setter方法上面 (默认byName) 引用资源 按名称@Resource(name=“”) 推荐使用该注解
<context:component-scan base-package="org.example"/>
@Commponent 通过@Resource引入 相当于xml中的被引用的beanid所属的对象
@Scope
初始化:@PostConstruct=init-method
@PreDestroy=destroy-method
- IOC、Spring的IOC
- Spring IoC
- [Spring]IoC
- Spring IOC
- Spring IOC
- spring IOC
- Spring IOC
- Spring IOC
- Spring Ioc
- Spring IoC
- spring ioc
- Spring IOC
- spring IOC
- Spring Ioc
- Spring IoC
- Spring IOC
- Spring IOC
- Spring IoC
- leetcode 每日一题 107. Binary Tree Level Order Traversal II
- 数组元素的赋值和遍历数组
- LeetCode之338—-Counting Bits
- hdu 1421(dp)
- 利用TouchesBegan解决页面内 触摸 某个视图以外的处理的情况
- Spring--IOC
- 懒马效应
- java中静态代码块的用法 static用法详解
- 【leetcode】Array——Best Time to Buy and Sell Stock I/II/III
- [提权禁区]利用vbs添加管理员用户
- struts的DevMode模式问题
- 大整数相乘(包含小数)
- 工厂方法模式--要车,轮子你得帮我装!
- mongodb技巧总结