记录 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。
欺骗自己最简单,欺骗自己最困难。
安慰自己最简单,安慰自己最困难。