一、在其他xml配置文件中引用

在maven项目中scr/main/resource 中新建properties文件夹存放项目中各种环境下的配置文件


wKiom1chySOxcdlPAAAhhshyHWw776.png

在配置文件中以键值对形式写好后,在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}"

仅作为个人知识点的积累,共同学习