spring读取项目外部property配置文件
来源:互联网 发布:内增高女鞋皮面淘宝 编辑:程序博客网 时间:2024/05/21 02:35
相较于传统的读取property配置文件的方法,为了数据的安全常把数据源配置与工程分类,放在项目的外部。
配置方法:
在spring的applicationContext文件中添加如下代码:
<context:property-placeholder location="file:C:/conf/config.properties" order="1" ignore-resource-not-found="true" ignore-unresolvable="true" /> <context:property-placeholder location="classpath*:/config.properties" order="2" ignore-resource-not-found="true" ignore-unresolvable="true" />
order代表加载顺序,当1加载成功 2不会覆盖1中的内容,1加载不成功加载2。
也可以通过bean的方式:
<bean id="property" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="order" value="1"/> <property name="ignoreResourceNotFound" value="true"/> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="location" value="file:C:/conf/config.properties"/> </bean>
0 0
- spring读取项目外部property配置文件
- spring中读取数据库的property配置文件
- spring配置文件中读取外部参数
- java读取配置文件property
- Java读取Property配置文件
- Java读取Property配置文件
- Java读取property配置文件
- java读取property配置文件
- 利用Spring的propertyConfigurer类 读取.property数据库配置文件
- Spring利用propertyConfigurer类 读取.property数据库配置文件
- 利用Spring的propertyConfigurer类 读取.property数据库配置文件
- spring项目打JAR包读取配置文件
- Spring中用context:property-placeholder给项目装载配置文件
- property配置文件读取工具类
- Spring配置文件加载外部配置文件
- spring 引入外部配置文件
- Spring配置文件<context:property-placeholder>
- spring配置文件<context:property-placeholder>
- 基本数据类型和封装类对照表
- Javascript或jQuery方法产生成指定范围90-100随机整数
- 关于在Ubuntu下进行下载安装及卸载VMware workstation
- android selector的用法
- android 自定义Dialog.Builder弹出框
- spring读取项目外部property配置文件
- kettle 命令行运行作业(kitchen)和转换(pan)以及一路下来编写的例子
- android Tab案例
- 有关锚点的问题
- android ViewPager案例
- android 点击底部图片进行切换不同的Fragment
- Teamalk在服务端新增协议
- 有效好用组件之启动屏react-native-splash-screen
- android:exported 属性详解