记录 spring 使用@Value获取properties文件中的属性值


使用@Value(${xxx}) 获取properties文件的属性值  只需要在spring的配置文件中添加bean。

1     <bean id="propertyConfigurer" 
2         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
3         <property name="location">
4             <value>classpath:config.properties</value>
5         </property>
6     </bean> 

有多个文件需要加载的话 可以在 property 标签中添加一个 list 标签存放的多个value。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM