三.Spring配置文件详解随笔
来源:互联网 发布:免id下载软件 编辑:程序博客网 时间:2024/05/16 11:28
一.
Bean 元素说明
attributes:idnameclassparentabstractscopelazy-initautowiredependency-checkdepends-oninit-methoddestroy-methodfactory-methodfactory-bean子元素:descriptionconstructor-argpropertylookup-methodreplace-method
二.
Bean property:设置类属性值
字面值: <property name=“maxSpeed”> <value>200</value> </property> <property name=“brand”> <value><![CDATA[红旗&CA72]]</value> </property>引用其他Bean:public class Boss{ private Car car; public void setCar(Car car) { this.car = car; }}<bean id=“car” class=“***”/><bean id=“boss” class=“***”> <property name=“car”> <ref bean=“car”></ref> </property></bean>内部Bean:<bean id=“boss” class=“***”/> <property name=“car”> <bean class=“***” > <property name=“price” value=“200”> </bean> </property></bean>null值:<null/>级联:public class Boss{ private Car car = nea Car(); public void setCar(Car car) { this.car = car; }}<bean id=“boss” class=“***”> <property name=“car.brand”> <value>奔驰E级</value> </property></bean>属性(List):public class Boss{ private List favorites = new ArrayList(); public List getFavorites() { return favorites; } public void setFavorites(List favorites) { this.favorites = favorites; }}<bean id=“boss” class=“***”> <property name=“favorites”> <list> <value>唱歌</value> <value>运动</value> <value>读书</value> </list> </property></bean>属性(Set):和List差别不大属性(Map):public class Boss{ private Map favorites; public Map getFavorites() { return favorites; } public void setFavorites(Map favorites){ this.favorites = favorites; }}<bean id=“boss” class=“***”> <property name=“favorites”> <map> <entry> <key><value>key01</value></key> <value>唱歌</value> </entry> <entry> <key><value>key02</value></key> <value>唱歌</value> </entry> </map> </property></bean>集合合并:<bean id=“parentBoss”abstract=“true”class=“***”> <property name=“favorites”> <set> <value>唱歌</value> <value>运动</value> <value>看书</value> </set> </property></bean><bean id=“childtBoss”parent=“parentBoss”> <property name=“favorites”> <set merge=“true”> <value>旅游</value> <value>睡觉</value> </set> </property></bean>自动装配:autowire=“byName”autowire=“ byType ”autowire=“ constructor ”autowire=“ autodetect ”属性注入方法:Public class Car { private String brand; public void setBrand(String brand) { this.brand = brand; } public String getBrand() { return this.brand; }}<bean id=“car” class=“com.jike.***.Car” > <property name=“brand”> <value>奔驰</value> </property></bean>构造函数注入:工厂方法注入:三.--Bean 的依赖关系:继承、依赖、引用继承:<bean id=“abstractCar” class=“com.jike.***.Car”/ p:brand=“奔驰E300” p:price=“2000” p:color=“黑色” abstract=“true”> ①<bean id=“car1” p:color=“红色” parent=“abstractCar” />②<bean id=“car1” p:color=“白色” parent=“abstractCar” />③依赖:保证Bean依赖的Bean已初始化<bean id=“manager” class=“com.jike.***.CacheManager” depends-on=“sysInit”; /> ①<bean id=“sysInit” class=“com.jike.***.SysInit” /> ② 引用:idref
0 0
- 三.Spring配置文件详解随笔
- Spring (三)配置文件详解
- (三)Spring Boot配置文件详解
- Spring配置文件详解三:Spring声明式事务管理
- JAVA随笔篇三(读写Properties配置文件以及路径问题详解)
- SSM整合(三) -- Spring和Mybatis的配置文件详解
- spring随笔(三)DataBase
- logback配置文件详解(三)
- spring 框架配置文件详解
- spring配置文件详解
- spring struts 配置文件详解
- spring struts 配置文件详解
- 详解Spring的配置文件
- 详解Spring的配置文件
- 详解Spring的配置文件
- 详解Spring的配置文件
- Spring配置文件详解
- Spring配置文件详解
- Redis教程(七) HyperLogLog类型
- sybase 动态sql
- Spring Boot 运行原理
- EL表达式中截取字符串的长度
- Unity 梯子生成算法
- 三.Spring配置文件详解随笔
- 购物神器:一款自动抓取淘宝商品内部优惠券的工具 http://www.bcyhq.cn/search.html
- it基础设施原理
- android 常用Adapter复制就用
- Redis教程(八) GEO地理位置
- c++之各种继承(单继承,多继承,菱形继承)
- 在Eclipse添加Android兼容包( v4、v7 appcompat )
- Spring 架构篇——基于 WebSocket 的消息推送
- CodeForces 634 A.Island Puzzle(水~)