spring注入properties类型的配置文件信息

来源:互联网 发布:java底层源代码 编辑:程序博客网 时间:2024/05/17 07:43

配置文件:

<!--PropertiesFactoryBeanproperties文件可用,可以用来注入properties配置文件的信息 -->

   <beanid="uploadProperties"class="org.springframework.beans.factory.config.PropertiesFactoryBean">

      <propertyname="location"value="classpath:xxxxx.properties"></property>

   </bean>


xxxxx.properties文件内容:

    path=e:\\testdir\\upload\\


在java中注入:

import org.springframework.beans.factory.annotation.Value;


    @Value("#{uploadProperties.path}")
    private  String  path;

阅读全文
0 0
原创粉丝点击