Spring 使用Properties配置文件(二)
2012-10-11 14:18
399 查看
重写占位符配置器PropertyOverrideConfigurer是Spring提供的一个容器后处理器,
它的属性文件指定的信息可以直接覆盖Spring XMl配置文件中的元数据。
也可以理解为:PropertyOverrideConfigurer属性文件是默认的配置信息
PropertyOverrideConfigurer属性文件,命名规则如下:
beanName.property=value
#dataSource beanName
dataSource.driverClassName=com.mysql.jdbc.Driver
dataSource.url=jdbc:mysql://127.0.0.1:3306/test
dataSource.username=root
dataSource.password=123
它的属性文件指定的信息可以直接覆盖Spring XMl配置文件中的元数据。
也可以理解为:PropertyOverrideConfigurer属性文件是默认的配置信息
PropertyOverrideConfigurer属性文件,命名规则如下:
beanName.property=value
#dataSource beanName
dataSource.driverClassName=com.mysql.jdbc.Driver
dataSource.url=jdbc:mysql://127.0.0.1:3306/test
dataSource.username=root
dataSource.password=123
<!-- 指定多个属性文件 --> <bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer"> <property name="locations"> <list> <value>jdbc.properties</value> </list> </property> </bean> <!-- 或者location指定文件 --> <context:property-override location="classpath:jdbc.properties"/> <!-- 尽管该Bean没有配置任何属性,但会读取jdbc.properties的信息 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> </bean>
相关文章推荐
- Spring配置文件中使用ref local与ref bean的区别. 在ApplicationResources.properties文件中,使用<ref bean>与<ref local>方法如下
- spring配置文件获取其他properties文件中的值及使用
- Spring使用配置文件读取jdbc.properties
- Spring无配置使用properties文件
- spring管理属性配置文件properties——使用PropertiesFactoryBean
- Spring学习笔记 在XML配置文件中使用properties文件的键值
- spring管理属性配置文件properties——使用PropertiesFactoryBean
- spring管理属性配置文件properties——使用PropertyPlaceholderConfigurer
- spring List,Set,Map,Properties,array的使用配置文件注入实例
- Spring学习笔记 在XML配置文件中使用properties文件的键值
- spring配置文件中分别使用多个properties文件
- Spring使用配置文件读取jdbc.properties
- Spring 使用Properties配置文件(一)
- Spring/Maven/MyBatis配置文件结合properties文件使用
- 【转】spring管理属性配置文件properties——使用PropertiesFactoryBean|spring管理属性配置文件properties——使用PropertyPlaceholderConfigurer
- Spring 中使用jasypt对配置文件(.properties)中密码加密
- JdbcTemplae使用入门&&Spring三种连接池配置&&Spring配置文件引用外部properties文件
- 让spring的配置文件可以使用外部properties里的参数。
- 第三节:SpringBoot使用properties配置文件实现多环境配置
- Spring无配置使用properties文件