你的位置:首页 > 软件开发 > Java > Spring基础——在Spring Config 文件中配置 Bean

Spring基础——在Spring Config 文件中配置 Bean

发布时间:2016-07-15 18:00:27
一、基于 1.通过属性注入即通过 setXxx() 方法注入 Bean 的属性值或依赖的对象。使用 <property name="" value="" ref=""/> 元素,其中 name 值为对应 ...

Spring基础——在Spring Config 文件中配置 Bean

一、基于

1.通过属性注入

即通过 setXxx() 方法注入 Bean 的属性值或依赖的对象。

使用 <property name="" value="" ref=""/> 元素,其中 name 值为对应 Bean 属性名称,value 指定对应属性值,ref 引用其他 Bean,value 属性和 ref 属性不可以同时存在。

也可以通过 <value></value> 子节点的方式指定属性值。

e:

<bean id="helloWorld" class="com.nucsoft.spring.helloworld.HelloWorld">  <property name="hello" value="spring"/>  <property name="world">    <value>spring</value>  </property></bean>

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:Spring基础——在Spring Config 文件中配置 Bean

关键词:Spring

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录