1.spring配置文件
<
bean
id
="configproperties"
class ="org.springframework.beans.factory.config.PropertiesFactoryBean" >
< property name ="location" value ="classpath:jdbc.properties" />
</ bean >
class ="org.springframework.beans.factory.config.PropertiesFactoryBean" >
< property name ="location" value ="classpath:jdbc.properties" />
</ bean >
2.读取属性方法
ApplicationContext c
=
new
ClassPathXmlApplicationContext(
"
classpath:applicationContext-datasource.xml
"
);
Properties p = (Properties)c.getBean( " configproperties " );
System.out.println(p.getProperty( " jdbcOrcale.driverClassName " ));
Properties p = (Properties)c.getBean( " configproperties " );
System.out.println(p.getProperty( " jdbcOrcale.driverClassName " ));