spring 加载资源文件

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的资源位置

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值