spring注入Properties

本文介绍了一种在Spring框架中将Properties文件注入到Bean的方法。通过配置`PropertiesFactoryBean`,可以指定多个Properties文件的位置,并将它们加载为可以在Bean中使用的属性集。此方法适用于需要从外部配置文件读取参数的场景。

最近项目中向将某个Properties注入到Bean中,经百度知以下代码.

<bean id="settings"   
   class="org.springframework.beans.factory.config.PropertiesFactoryBean">  
   <property name="locations">  
  <list>  
    <value>file:/opt/rms/config/rms-mq.properties</value>  
    <value>file:/opt/rms/config/rms-env.properties</value>  
  </list>  
   </property>  
 </bean>  
</beans> 

===
记录备忘

转载于:https://www.cnblogs.com/lyq-blogs/p/spring-properties.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值