spring配置文件中引用外部的properties文件
2012-04-06 23:24
363 查看
要在spring的xml中引用properties文件中定义的属性,需要进行特殊的加载,首先需要利用PropertyPlaceholderConfigurer
典型配置如下:
<bean id="common.propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="fileEncoding" value="UTF-8" />
<property name="locations">
<list>
<value>classpath*:conf/default-*.properties</value>
<value>classpath*:conf/*.properties</value>
</list>
</property>
</bean>
这个是调用的locations的list赋值方式,也可以单独一条
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:com/foo/jdbc.properties"/>
</bean>
properties中配置:
jdbc.driverClassName=org.hsqldb.jdbcDriver
下面的内容中,就可以通过
value="${jdbc.driverClassName}"
来访问properties的值
典型配置如下:
<bean id="common.propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="fileEncoding" value="UTF-8" />
<property name="locations">
<list>
<value>classpath*:conf/default-*.properties</value>
<value>classpath*:conf/*.properties</value>
</list>
</property>
</bean>
这个是调用的locations的list赋值方式,也可以单独一条
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:com/foo/jdbc.properties"/>
</bean>
properties中配置:
jdbc.driverClassName=org.hsqldb.jdbcDriver
下面的内容中,就可以通过
value="${jdbc.driverClassName}"
来访问properties的值
相关文章推荐
- JdbcTemplae使用入门&&Spring三种连接池配置&&Spring配置文件引用外部properties文件
- spring如何引用properties文件里的配置
- spring boot application.properties文件外部配置
- Springboot引用外部配置文件
- spring boot application.properties文件外部配置
- Spring配置中从外部文件加载多个properties文件
- Springboot引用外部配置文件
- Spring如何引用properties文件里的配置
- 可以从Jar外部加载JDBC.properties的Spring-mybatis配置文件
- 可以从Jar外部加载JDBC.properties的Spring-mybatis配置文件
- spring 配置中引用properties文件定義
- Springboot引用外部配置文件
- spring如何引用properties文件里的配置
- Spring - 配置Bean - 自动装配 关系 作用域 引用外部属性文件
- Spring 基于注解装配依赖对象和引用外部文件读取数据库配置
- Spring配置文件外部化配置及.properties的通用方法
- spring 配置文件中dbcp连接池,jdbc连接池 引入 配置文件properties,但是不能用$符号引用里面的变量问题
- Spring引用外部文件生成主键配置
- spring配置文件location引用外部文件
- spring的配置文件引用properties配置的详解