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_workspace\opc\conf
spring读取properties文件的更多相关文章
- 如何通过Spring读取Properties文件
		
1 在Spring中配置文件中, 配置配置文件的引用 <util:properties id="settings" location="/WEB-INF/c ...
 - Java-马士兵设计模式学习笔记-工厂模式-模拟Spring读取Properties文件
		
一.目标:读取properties文件,获得类名来生成对象 二.类 1.Movable.java public interface Movable { void run(); } 2.Car.java ...
 - spring 读取properties文件--通过注解方式
		
问题: 需要通过properties读取页面的所需楼盘的名称.为了以后便于修改. 解决: 可以通过spring的 PropertiesFactoryBean 读取properties属性,就不需要自己 ...
 - spring 框架的xml文件如何读取properties文件数据
		
spring 框架的xml文件如何读取properties文件数据 第一步:在spring配置文件中 注意:value可以多配置几个properties文件 <bean id="pro ...
 - spring使用@Value注解读取.properties文件时出现中文乱码问题的解决
		
解决办法 在spring中我们常常使用.properties对一些属性进行一个提前配置, spring 在读取*.properties文件时, 默认使用的是asci码, 这时 我们需要对其编码进行转换 ...
 - Spring 如何读取properties文件内容
		
http://hi.baidu.com/alizv/blog/item/d8cb2af4094662dbf3d38539.html 在现实工作中,我们常常需要保存一些系统配置信息,大家一般都会选择配置 ...
 - Spring下读取properties文件
		
由于在spring的xml文件中配置了 <bean id="validator" class="org.springframework.validation.bea ...
 - 五种方式让你在java中读取properties文件内容不再是难题
		
一.背景 最近,在项目开发的过程中,遇到需要在properties文件中定义一些自定义的变量,以供java程序动态的读取,修改变量,不再需要修改代码的问题.就借此机会把Spring+SpringMVC ...
 - classpath 及读取 properties 文件
		
java代码中获取项目的静态文件,如获取 properties 文件内容是必不可少的. Spring 下只需要通过 @Value 获取配置文件值 <!-- 资源文件--> <util ...
 
随机推荐
- 阻塞机制下的recv小结
			
recv是socket编程中最常用的函数之一,在阻塞状态的recv有时候会返回不同的值,而对于错误值也有相应的错误码,分别对应不同的状态,下面是我针对常见的几种网络状态的简单总结. 首先阻塞 ...
 - Android Configuration change引发的问题及解决方法
			
之前在学习Fragment和总结Android异步操作的时候会在很多blog中看到对Configuration Change的讨论,以前做的项目都是固定竖屏的,所以对横竖屏切换以及横竖屏切换对程序有什 ...
 - SharedPreferences的工具类,使用起来方便、快捷
			
SharedPreferences的工具类,使用起来方便.快捷:上代码:import android.content.Context;import android.content.SharedPref ...
 - Collections.unmodifiableList()的使用与场景
			
在<重构——改善既有代码的设计>一书中,有一种重构手法叫Encapsulate Collection(封装集群),为了演示该重构手法,我写了四个类,通过对比重构前后的代码,加深对这一重构手 ...
 - 与useradd命令相关的两个默认配置文件
			
Configuration Files for User Management Defaults When working with tools as useradd, some defaul ...
 - NYOJ 116士兵杀敌(二) 树状数组
			
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=116 士兵杀敌(一) 数组是固定的,所以可以用一个sum数组来保存每个元素的和就行,但是不 ...
 - TCP_DEFER_ACCEPT的坑
			
我实现了一个server,支持HTTP协议和内部私有协议,为了简化部署,我设计成一个端口同时兼容两种协议的客户端.根据连接后到达的消息头自动识别客户端协议.这种事情的传统做法是,accept后加入ep ...
 - C# 面向对象  , 类与对象
			
一,类的字段 类的字段, 就是类里面的 数据. 二,类的方法 1 , 函数的重载 , 如何判断: 是由两个或多个同名函数组成的,但是函数要有不同的参数.或个数.(参数 是函数的输入的东西) shu ...
 - pen: Local Testing
			
[踩点] * OLEViewer:查看 ActiveX 组件信息 [Fuzz] * Tools in This Article * COMRaider:ActiveX/ocx [utils] * Fi ...
 - Mysql group_concat
			
select p.id,p.parent_id,group_concat(distinct(CONCAT("分类名称:",c.name)) order by c.id desc s ...