當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
如何注入值到Spring bean属性
生活随笔
收集整理的這篇文章主要介紹了
如何注入值到Spring bean属性
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在Spring中,有三種方式注入值到?bean?屬性。
- 正常的方式
- 快捷方式
- “p”?模式
3. “p” 模式
通過使用“p”模式作為注入值到一個屬性。 <beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd"><bean id="FileNameGenerator" class="com.yiibai.common.FileNameGenerator" p:name="yiibai" p:type="txt" /></beans> 記住聲明?xmlns:p=”http://www.springframework.org/schema/p"?在Spring?XML?bean配置文件。 總結 這些方法的使用完全是基于個人喜好,也不會影響注入bean屬性的值。 http://www.yiibai.com/spring/how-to-define-bean-properties-in-spring.html總結
以上是生活随笔為你收集整理的如何注入值到Spring bean属性的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 任正非曾对华为名字不满意 华为名字竟然是
- 下一篇: 船舶驾驶台舵角指示器不显示正常值怎么回事