zoukankan      html  css  js  c++  java
  • spring 通过编程来获取属性文件

    配置可以读取属性:

    <beans profile="dev">
            <context:property-placeholder ignore-resource-not-found="true"
                                          location="classpath:/META-INF/config/dev/*.properties" />
        </beans>
    
        <beans profile="idc">
            <context:property-placeholder ignore-resource-not-found="true"
                                          location="classpath:/META-INF/config/idc/*.properties" />
        </beans>
    
        <beans profile="production">
            <context:property-placeholder ignore-resource-not-found="true"
                                          location="classpath:/META-INF/config/prod/*.properties" />
        </beans>
    
        <beans profile="test">
            <context:property-placeholder ignore-resource-not-found="true"
                                          location="classpath:/META-INF/config/test/*.properties" />
        </beans>

    也可以通过编程的形式获取文件属性:

    Resource resource = new ClassPathResource("/my.properties");
    Properties props = PropertiesLoaderUtils.loadProperties(resource);

    参考文献:

    【1】http://stackoverflow.com/questions/1771166/access-properties-file-programatically-with-spring

  • 相关阅读:
    图片滚动
    DOM 练习
    HTML 求阶乘之和
    JavaScript 累加求和练习 函数
    JavaScript 累加求和练习
    JavaScript
    汽车之家官网首页排版与布局
    网页搜索页面排版布局
    转---Python——numpy random类
    转---redshift database ---学习
  • 原文地址:https://www.cnblogs.com/davidwang456/p/4861855.html
Copyright © 2011-2022 走看看