首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring配备中调用properties文件

2012-09-10 
spring配置中调用properties文件system.propertiesdatabase.urljdbc:mysql://localhost/smapledatabase.d

spring配置中调用properties文件

system.properties


database.url=jdbc:mysql://localhost/smaple
database.driver=com.mysql.jdbc.Driver
database.user=root
database.password=root

2.applicationContext.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<bean id="propertyConfigurer"

????? value="classpath:example4/helloworld.properties"/>
</bean>

helloworld.properties:
fileHelloWorld.statusname=this is status Name;

如果少了${fileHelloWorld.statusname}中少了Bean名称fileHelloWorld,会导致错误发生
这应该是种强制某个配置是属性某个Bean

3.PropertyPlaceholderConfigurer的配置不需要考虑Bean的名称,直接配置就可以了
配置方式和PropertyOverrideConfigurer类似

热点排行