springmvc怎么读取配置文件

如题所述

1、在spring-mybatis配置文件中引入配置文件,代码如下:

[html] view plain copy
<span style="font-family:Comic Sans MS;"> <!-- 引入配置文件 -->
<bean id="prpertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean></span>

2、为了让controller读取到配置文件,仍需要在spring.xml文件中引入配置文件

[html] view plain copy
<span style="font-family:Comic Sans MS;"><context:property-placeholder location="classpath:jdbc.properties" /></span>
温馨提示:答案为网友推荐,仅供参考