記錄 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