spring 读取资源文件方法

1.spring配置文件

<bean id="configproperties" 
         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"));
原文地址:https://www.cnblogs.com/yg_zhang/p/2129117.html