记录 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。

posted @ 2019-07-17 14:43  不要西红柿  阅读(1751)  评论(0编辑  收藏  举报