spring 读取properties的两种方法
来源:互联网 发布:php产品管理系统 编辑:程序博客网 时间:2024/05/17 23:05
1.在配置文件中配置PropertyPlaceholderConfigurer
- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="locations" value="classpath:com/foo/jdbc.properties"/>
- </bean>
然后在需要的地方直接以下方式引用:
- <property name="url" value="${jdbc.url}"/>
2.在配置文件中加入
beans的命名空间声明如下:
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
用到了
- xmlns:context=http://www.springframework.org/schema/context
配置如下:
- <context:property-placeholder location="dbconf.properties"/>
- spring 读取properties的两种方法
- spring 读取properties的两种方法
- spring 读取properties的两种方法
- spring 读取properties的两种方法
- Spring读取外部的.properties文件内容并设置给bean的两种方法
- spring读取properties的方法
- spring读取properties的方法
- 读取属性文件(.properties)的两种方法
- 如何读取.properties文件配置的两种方法
- spring读取xml的两种方法
- spring中配置jdbc.properties的两种方法
- 读取.properties文件的两种方式
- Spring加载properties的两种方式
- 读取properties的方法
- 读取properties的方法
- 读取properties的方法
- java解析properties的两种方法
- spring读取properties和xml配置文件的方法
- Qt 之路 (02)—你好,世界!
- 如何在AODV(NS-2)中实现混杂模式并且实现邻居监测功能
- 如何查看class文件对应的JDK版本
- ios UIWindow & UIWindowLevel
- 入门视频采集与处理(显示YUV数据)
- spring 读取properties的两种方法
- 使用双缓存贴图时切换时仍然会卡的解决方法,贴图之前用FillSolidRect()
- Java Socket编程 - 基于Socket实现HTTP下载客户端
- “sessionFactory " or "hibernateTemplate " is required异常
- 中小团队玩转AppStore全攻略
- 杂记之C语言之位倒序和字符串倒序
- ios错误码
- 单例模式
- (6)包含多个段的程序