spring读取properties文件
2015-11-27 18:37
429 查看
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
<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
相关文章推荐
- JavaEE_Mybatis_SpringMVC_Mybatis_lesson1 _ 原始的类似于 JDBC 开发
- Java 结构体排序
- win7 64位操作系统配置eclipse+android+cdt环境(各种变态错处理)
- eclipse myeclipse 单步调试
- java 使用sourceforge.pinyin4j查询汉字拼音
- java报“非法字符: \65279 ”错误的解决方法
- eclipse 修改中英文显示
- java hdu2087
- 正则表达式判断用户昵称
- 在Spring3中,配置DataSource的方法有6种。
- Spring学习之对JDBC的支持
- 关于JAVA、 JAVA Web项目导入数据库驱动包的问题
- hibernate单向1-1无表连接级联
- Java synchronized详解
- Java大数处理
- Java初始化
- Axis2+spring整合实例
- Struts2中Session的使用方法详细解释
- java中json包的使用以及字符串,map,list,自定义对象之间的相互转换
- springmvc配置servlet的拦截形式/*和/的区别