10011---使用外部属性文件
来源:互联网 发布:昆明行知中学 编辑:程序博客网 时间:2024/05/22 11:58
-
•在配置文件里配置 Bean 时,有时需要在Bean 的配置里混入系统部署的细节信息(例如:文件路径,数据源配置信息等).
而这些部署细节实际上需要和Bean配置相分离
•Spring 提供了一个 PropertyPlaceholderConfigurer的BeanFactory后置处理器,这个处理器允许用户将Bean配置的部分内容外移到属性文件中.
可以在 Bean 配置文件里使用形式为${var}的变量,PropertyPlaceholderConfigurer从属性文件里加载属性,并使用这些属性来替换变量.
Spring 还允许在属性文件中使用${propName},以实现属性之间的相互引用。
注册 PropertyPlaceholderConfigurer
•可通过 <context:property-placeholder>元素简化:
–<beans> 中添加 context Schema 定义
–在配置文件中加入如下配置:
-------------
----
ApplicationContext cxt = new ClassPathXmlApplicationContext("beans-properties.xml");javax.sql.DataSource ds = (javax.sql.DataSource) cxt.getBean("dataSource");System.out.println(ds.getConnection());
0 0
- 10011---使用外部属性文件
- spring 使用外部属性文件
- 4、使用外部属性文件
- Spring 使用外部属性文件
- Spring_8_使用外部属性文件
- Spring使用外部属性文件
- Spring使用外部属性文件
- spring-使用外部属性文件
- Spring 使用外部属性文件
- spring使用外部属性文件
- spring使用外部属性文件
- spring ioc之使用外部属性文件
- Spring IOC使用外部属性文件
- Spring 使用外部属性文件(连接数据库)
- Spring-Bean配置-使用外部属性文件
- Spring 中如何使用外部属性文件
- (八)spring_使用外部属性文件
- Spring-7:使用外部属性文件
- Ubuntu 12.04 使用Eclipse搭建C/C++编译环境
- Android Studio——R文件小问题
- 关于 Arrays.asList add、remove 操作的 UnsupportedOperationException
- 10010---bean 的作用域:singleton;prototype;WEB 环境作用域
- vijos-p1002-过河
- 10011---使用外部属性文件
- [kuangbin带你飞]专题二 搜索进阶 I - A计划(HDU 2102)
- 1020. Tree Traversals (25) (重建二叉树)
- SQL Server 访问发送Http请求
- 2015 naver's Reading List
- 常用嵌入式文件系统介绍
- linux shell对应的配置文件是怎么被执行的呢?-----聊聊/etc/profile, ~/.bash_profile, ~/.bashrc等配置文件的执行流程
- Android之集成友盟推送功能
- 字符串的处理