經常可以在spring配置文件中看到如下配置
<property name="locations">
<list>
<value>classpath:db.properties</value>
</list>
</property>
</bean>
org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer
應用啓動時首先使用用戶自定義的變量,然後使用系統變量,然後是這個配置的變量。也就是說在db.properties裏配置的屬性可在spring配置文件中以${....}形式訪問,例如
<property name="host" value="${db.host}"/>
<property name="username" value="${db.username}"/>
<property name="password" value="${db.password}"/>
</bean>
以上粗體變量都是mail.properties中定義的。