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_workspace\opc\conf

spring读取properties文件的更多相关文章

  1. 如何通过Spring读取Properties文件

    1 在Spring中配置文件中, 配置配置文件的引用     <util:properties id="settings" location="/WEB-INF/c ...

  2. Java-马士兵设计模式学习笔记-工厂模式-模拟Spring读取Properties文件

    一.目标:读取properties文件,获得类名来生成对象 二.类 1.Movable.java public interface Movable { void run(); } 2.Car.java ...

  3. spring 读取properties文件--通过注解方式

    问题: 需要通过properties读取页面的所需楼盘的名称.为了以后便于修改. 解决: 可以通过spring的 PropertiesFactoryBean 读取properties属性,就不需要自己 ...

  4. spring 框架的xml文件如何读取properties文件数据

    spring 框架的xml文件如何读取properties文件数据 第一步:在spring配置文件中 注意:value可以多配置几个properties文件 <bean id="pro ...

  5. spring使用@Value注解读取.properties文件时出现中文乱码问题的解决

    解决办法 在spring中我们常常使用.properties对一些属性进行一个提前配置, spring 在读取*.properties文件时, 默认使用的是asci码, 这时 我们需要对其编码进行转换 ...

  6. Spring 如何读取properties文件内容

    http://hi.baidu.com/alizv/blog/item/d8cb2af4094662dbf3d38539.html 在现实工作中,我们常常需要保存一些系统配置信息,大家一般都会选择配置 ...

  7. Spring下读取properties文件

    由于在spring的xml文件中配置了 <bean id="validator" class="org.springframework.validation.bea ...

  8. 五种方式让你在java中读取properties文件内容不再是难题

    一.背景 最近,在项目开发的过程中,遇到需要在properties文件中定义一些自定义的变量,以供java程序动态的读取,修改变量,不再需要修改代码的问题.就借此机会把Spring+SpringMVC ...

  9. classpath 及读取 properties 文件

    java代码中获取项目的静态文件,如获取 properties 文件内容是必不可少的. Spring 下只需要通过 @Value 获取配置文件值 <!-- 资源文件--> <util ...

随机推荐

  1. 在linux后台执行脚本

    1. 使用&符号在后台执行命令 你可以在Linux命令或者脚本后面增加&符号,从而使命令或脚本在后台执行,例如:. $ ./my-shell-script.sh & 2. 使用 ...

  2. sql循环遍历

    <sql id="Example_Where_Clause" > <!-- WARNING - @mbggenerated This element is aut ...

  3. Swift中面向协议的编程

    什么是面向协议的编程? 面向协议的编程,是一种编程范式. 编程范式,是一个计算机科学用语.维基百科中的解释是,计算机编程的基本风格或典型模式.通俗来说,就是解决某一个问题的方法不同方法和思路. 像大家 ...

  4. mui实现支付宝支付功能

    <!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>H ...

  5. activiti_SpringEnvironment

    package main; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; i ...

  6. SQL查询表字段、字段说明、类型、长度、主键

    SELECT  表名=d.name,case when a.colorder=1 then d.name else '' end, 字段序号=a.colorder, 字段名=a.name, 标识=ca ...

  7. GUI树组件,表格

    树组件首先要new一个JTree,再加结点,然后添加到 JScrollPane JTree tree1=new JTree(); //.......添加节点 add(new ScrollPane(tr ...

  8. rpc和websocket的区别

    虽然很久以前用过rpc但是当时没用过websocket,也没做过对比,现在就对比一下 rpc的用法是客户端直接调用服务端的函数,其实他就是把数据传给服务端,服务端处理完以后返回给客户端, websoc ...

  9. 自定义控件学习之菜鸟笔记一(Hello World)

    一:引言 正在学习自定义控件的开发内容,做为菜鸟勤做笔记自然是必要任务了.本篇为本人学习自定义控件的学习笔记,借此和大家分享一下学习过程吧. 本人学习喜欢先看到具体的实例,然后再深入学习,故先从一个简 ...

  10. IE6浏览器兼容问题及部分解决方案(网上整理)

    作为一个初涉前端技术的IT菜鸟,IE浏览器的兼容问题是一个不得不跨越的坎.为了能够在不同浏览器达到同样的显示效果,就不得不花心思想出办法实现兼容.由于各大主流浏览器内核不同,各自的实现标准有所差异,因 ...