如何使jdbc配置文件分离出来支持动态修改

203 阅读1分钟
  1. 将jdbc.properties配置文件放到外面
  2. 修改spring配置文件(一般是sprng_mybaits.xml),替换加载jdbc文件的路径为刚才创建的文件夹下的配置文件路径
<!-- 引入并加载jdbc配置文件 -->
	<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>file:${catalina.home}/jdbc_conf/jdbc.properties</value>
			</list>
		</property>
	</bean>

${catalina.home}为自动获取的tomcat根目录