spring 读取properties的两种方法
来源:互联网 发布:java语言的特点 编辑:程序博客网 时间:2024/05/19 01:59
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配置文件的方法
- 代码评审的真相
- 购房(摘抄)
- + 线程安全的单例模式
- 具有伸缩效果的ListView(带有其他效果)
- cloudstack中的user,account,domain和project解释--之一
- spring 读取properties的两种方法
- 查找iframe里面的元素
- 韦东山视频实验之Input子系统分析之一
- RedHat下安装MYSQL 5.5
- JS设计模式
- iframe 调用asp页面实现动态数据展示
- cloudstack中的user,account,domain和project解释--之二
- VC++中轻松实现滑动(Slider)控件
- linux平台下进行thrift和protobuf的IDL文件的编译缺少类库的解决办法