在applicationContext.xml中引入jdbc.properties文件

来源:互联网 发布:定性与定量数据区别 编辑:程序博客网 时间:2024/05/19 04:29


方式一:

通过context标签引入

<!-- 通过context标签引入jdbc.properties --><context:property-placeholder location="classpath:jdbc.properties"/>


方式二:


<!-- 使用spring自带的占位符替换功能 --><beanclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><!-- 允许JVM参数覆盖 --><property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /><!-- 忽略没有找到的资源文件 --><property name="ignoreResourceNotFound" value="true" /><!-- 配置资源文件 --><property name="locations"><list><value>classpath:jdbc.properties</value></list></property></bean>

提示:此处不加classpath也行,因为jdbc.properties就放在类路径下,一般加上。


阅读全文
0 0
原创粉丝点击