zoukankan      html  css  js  c++  java
  • spring读取properties文件

    1.方式一

    <util:properties id="meta" location="classpath:config/metainfo.properties" />

    @Value("#{meta['pubVersion']}")
        private String pubVersion

    2方式二:

        <bean id="configPropertiesTest" class="org.springframework.beans.factory.config.PropertiesFactoryBean">  
           <property name="locations">  
               <list>  
                   <value>file:${global.config.path}/opc/opc-business/jdbc.write.properties</value>
                   <value>file:${global.config.path}/opc/opc-business/jdbc.read.properties</value>
               </list>  
           </property>  
        </bean>

        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">  
            <property name="properties" ref="configPropertiesTest" />  
        </bean>

      @Value("#{configPropertiesTest['jdbc.read.username']}")
          private String testKey;

    启动时加入参数 -Dglobal.config.path=E:opc_workspaceopcconf

  • 相关阅读:
    groovy 执行shell
    expect 用法
    shebang解释
    docker 安装
    centos7 lvm添加硬盘后扩展磁盘空间
    scoped的原理和deep深度选择器的妙用
    swagger3
    帮评网
    反射工具
    网络只能传输二进制
  • 原文地址:https://www.cnblogs.com/liuzy2014/p/5001487.html
Copyright © 2011-2022 走看看