.properties配置文件中的常量在xml文件中的引用
在配置文件中以键值对形式写好后,在spring配置文件中将配置文件初始化成Bean,然后就可以在其他xml文件中以${…}形式引用
<!-- 初始化properties配置文件成bean-->
<bean id="configProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<!--oracle数据源 -->
<value>classpath:properties/oracle.db.properties</value>
<value>classpath:properties/system.properties</value>
<!-- 线上环境 -->
<!-- <value>classpath:properties/www.properties</value> -->
<!-- 公司测试环境 -->
<!-- <value>classpath:properties/rewww.properties</value> -->
<!-- 公司开发环境 -->
<value>classpath:properties/dohko.properties</value>
</list>
</property>
</bean>
在其他xml中以${…}形式引用
<property name="driverClassName" value="${sys.database.driverClassName}"
参考自:https://blog.51cto.com/534256702/1768701