使用@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。