spring 加载配置文件
通过xml方式加载
1.
<context:property-placeholder location="classpath:db-config.properties" ignore-unresolvable="true" />
2.
<!-- 第二种方式是使用注解的方式注入,主要用在java代码中使用注解注入properties文件中相应的value值 -->
<bean id="prop" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations"><!-- 这里是PropertiesFactoryBean类,它也有个locations属性,也是接收一个数组,跟上面一样
<array>
<value>classpath:public.properties</value>
</array>
</property>
</bean>
location: 指定了properties的资源位置