- 浏览: 1596438 次
- 性别:
- 来自: 吉林
-
文章分类
- 全部博客 (624)
- C/C++ (33)
- Java (181)
- 网络相关 (7)
- 我爱篮球 (3)
- 也爱足球 (4)
- 杂谈 (1)
- 系统架构 (3)
- Web Service (14)
- Framework (3)
- 系统命令 (8)
- 管理平台相关 (8)
- 其它 (35)
- Websphere (1)
- Struts2 (24)
- Hibernate (16)
- Spring (23)
- javascript (20)
- jquery (23)
- html/css/div (28)
- 数据库 (40)
- JavaWeb (27)
- 设计模式 (2)
- 文档编写 (3)
- SVN (5)
- Ant (1)
- Maven (13)
- 软件项目管理 (8)
- AOP (1)
- kindeditor (1)
- JSON (2)
- Servlt/JSP (4)
- WordXML (2)
- XML (12)
- 面试相关 (7)
- Tomcat (11)
- 性能与调优 (29)
- 职业发展 (2)
- 操作系统 (7)
- AJAX (2)
- DWR (1)
- Eclipse (12)
- 持续集成 (3)
- 批处理命令 (1)
- Mozilla Rhino (2)
- 新鲜技术 (18)
- Apache mina (2)
- 底层技术 (18)
- Linux (22)
- 新鲜技术,IT历史 (1)
- 敏捷开发 (1)
- 版本控制 (5)
- 较火技术 (7)
- 集群 (2)
- Web前端 (13)
- 报表工具 (3)
- 网站架构 (5)
- 大数据 (8)
- 分布式存储 (5)
- 云计算 (8)
- TCP/IP协议 (1)
- 负载均衡 (3)
- 硬件 (1)
- 表现层技术 (3)
- Velocity (3)
- jvm (6)
- 并发编程 (10)
- hadoop (8)
- 数据结构和算法 (12)
- 计算机原理 (1)
- 测试驱动开发-TDD (3)
- 开发技巧 (1)
- 分词器 (1)
- 项目构建工具 (2)
- JMX (4)
- RMI (1)
- 测试技术 (22)
- 网络完全 (1)
- Git (4)
- apache开源包 (4)
- Java常用 (1)
- mock (2)
- OSGi (2)
- MongoDB (1)
- JBPM (1)
- Storm (3)
- mysql (2)
- telnet (1)
- 正则表达式 (1)
- bootstrap (4)
- Apache ActiveMQ (1)
- redis (9)
- Nginx (2)
- rsync+inotify文件同步 (2)
- testng (1)
- 原型设计工具 (1)
- 工程能力 (1)
- 风险控制 (3)
- ibatis (1)
- 分布式 (4)
- 安全技术 (1)
- 计算机基础 (4)
- 消息中间件 (1)
- UML (2)
最新评论
-
u012236967:
java命令执行jar包(里面的main函数)的方式(包括依赖其它的jar包问题) -
世界尽头没有你:
Selenium自动化测试从入门到精通(Java版)百度网盘地 ...
自动化测试工具 Selenium WebDriver 入门教程(针对主流浏览器) -
小小西芹菜:
我喜欢代码简洁易读,服务稳定的推送服务,前段时间研究了一下go ...
dwr实现Reverse Ajax推送技术的三种方式 -
hellozhouqiao:
楼主,请教一点问题.现在我们需要在excel 的页脚里面加上图 ...
FreeMaker + xml 导出word(处理目录,图片和页眉页脚问题) -
乱在长安:
使用Timer会有各种各样的问题好嘛?!书上推荐使用Sched ...
DelayQueue (ScheduledThreadPoolExecutor调度的实现)
PropertyPlaceholderConfigurer可以将上下文(配置文件)中的属性值放在另一个单独的标准java Properties文件中去。这样的话,我只需要对properties文件进行修改,而不用对xml配置文件进行修改。 作用是什么呢? 有一些属性值不需要经常变更,但是有一些属性值可能随时改变,把经常会改动的属性值放在另一个文件中的话,程序使用起来也更方便。
PropertyPlaceholderConfigurer可以读取在Properties文件中的配置。 applicationContext.xml <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
init.properties datasource.driverClassName=com.mysql.jdbc.Driver #datasource.driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver datasource.maxActive=10 #datasource.defaultAutoCommit=true datasource.whenExhaustedAction=1 hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect hibernate.jdbc.batch_size=25 Test.java Resource res = new ClassPathResource("applicationContext.xml"); /*不在applicationContext.xml配置PropertyPlaceholderConfigurer //配置PropertyPlaceholderConfigurer IfCaculate caculateService = (IfCaculate) factory IfListAll listAll = (IfListAll) factory.getBean("listService"); |
<bean id="propertyConfigurerForAnalysis" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>classpath:/spring/include/dbQuery.properties</value> </property> </bean> 其中classpath是引用src目录下的文件写法。
当存在多个Properties文件时,配置就需使用locations了:(2)
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/spring/include/jdbc-parms.properties</value> <value>classpath:/spring/include/base-config.properties</value> </list> </property> </bean>
接下来我们要使用多个PropertyPlaceholderConfigurer来分散配置,达到整合多工程下的多个分散的Properties 文件,其配置如下:(3)
<bean id="propertyConfigurerForProject1" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="order" value="1" /> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="location"> <value>classpath:/spring/include/dbQuery.properties</value> </property> </bean>
<bean id="propertyConfigurerForProject2" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="order" value="2" /> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="locations"> <list> <value>classpath:/spring/include/jdbc-parms.properties</value> <value>classpath:/spring/include/base-config.properties</value> </list> </property> </bean>
其中order属性代表其加载顺序,而ignoreUnresolvablePlaceholders为是否忽略不可解析的 Placeholder,如配置了多个PropertyPlaceholderConfigurer,则需设置为true
至此你已经了解到了如何使用PropertyPlaceholderConfigurer,如何使用多个Properties文件,以及如何配置多个PropertyPlaceholderConfigurer来分解工程中分散的Properties文件。至于 PropertyPlaceholderConfigurer还有更多的扩展应用,如属性文件加密解密等方法 |
发表评论
-
可以学习很多东西的博客(Appfuse以及其它管理平台相关的东西)
2011-04-29 15:40 1127http://www.blogjava.net/liuwent ... -
Appfuse中web.xml配置内容(补充)
2011-04-29 15:30 1429Spring中,BeanFactory 提供了一种先进的配置 ... -
Appfuse中web.xml配置内容(转)
2011-04-29 15:17 2196出自:http://apps.hi.baidu.com/sha ... -
web.xml中的一些东西
2011-04-29 15:01 1389官网:http://www.opensymphon ... -
DWR的使用
2011-04-28 13:19 955DWR官网:http://directwebremoting. ... -
Spring Security 几篇好文章
2011-04-27 17:03 1070http://www.blogjava.net/redhatl ... -
Spring JTA应用JOTM:StandardXAPoolDataSource的使用
2011-04-27 15:03 3069本节将介绍JOTM在Spring中的配置。 JOTM(Jav ...
相关推荐
Spring 中 PropertyPlaceholderConfigurer 的使用 PropertyPlaceholderConfigurer 是 Spring 框架中的一个重要组件,用于加载和管理 Properties 文件。它能够将 Properties 文件中的键值对注入到 Spring 的 bean 中...
在Spring框架中,属性占位符`PropertyPlaceholderConfigurer`是一个重要的工具,用于处理配置文件中的属性值引用。它使得我们可以在XML配置文件中使用占位符`${...}`来引用外部属性文件中的值,从而使应用配置更加...
在Spring框架中,Bean的配置与管理是其核心功能之一,而通过`PropertyPlaceholderConfigurer`进行属性占位符的配置则是实现动态配置的关键技术。本文将深入解析如何利用`PropertyPlaceholderConfigurer`进行bean配置...
以上就是关于"Spring PropertyPlaceholderConfigurer配置文件加载器集成ZooKeeper来实现远程配置读取"的详细解释,涵盖了Spring的配置处理、ZooKeeper的使用以及两者结合的实现过程。理解并掌握这一技术,有助于提升...
Spring如何使用PropertyPlaceholderConfigurer读取文件 Spring框架中,PropertyPlaceholderConfigurer是一个非常重要的组件,它可以帮助我们读取配置文件,实现系统的配置信息统一管理。在大型项目中,我们往往会将...
`spring1.docx`和`spring2.docx`可能是两份关于Spring框架的文档,可能包含了更多关于`PropertyPlaceholderConfigurer`的使用示例、最佳实践以及与其他Spring特性(如`@Value`注解、`@ConfigurationProperties`等)...
在Spring框架中,`PropertyPlaceholderConfigurer`是一种特殊的Bean,它被用来处理Spring配置文件中的占位符(placeholder),并将它们替换为具体的值。这些值通常来自外部的属性文件,如`.properties`或`.xml`等。...
- **通过实例工厂方法创建 Bean**:使用非静态工厂方法来创建 Bean 实例。 - **Bean的标识**:每个 Bean 都有一个唯一的标识符(id 或 name)。 - **Singleton 的使用与否**:默认情况下,Bean 采用 Singleton ...
不使用XML定义档进行 Bean设置 Aware 相关介面 BeanPostProcessor BeanFactoryPostProcessor PropertyPlaceholderConfigurer PropertyOverrideConfigurer CustomEditorConfigurer ...
6.8.1. 在Spring中使用AspectJ来为domain object进行依赖注入 6.8.1.1. @Configurable object的单元测试 6.8.1.2. 多application context情况下的处理 6.8.2. Spring中其他的AspectJ切面 6.8.3. 使用Spring IoC来...
Spring默认的`PropertyPlaceholderConfigurer`不直接支持加密的属性文件,但它提供了扩展点,允许我们自定义实现来处理加密后的属性。以下是一种实现方式: 1. 创建一个自定义的`PropertyPlaceholderConfigurer`...
在Spring框架中,数据库连接池是管理数据库连接的关键组件,它能有效地提高应用程序的性能和资源利用率。...同时,随着Spring的发展,现在更推荐使用HikariCP作为默认的连接池,因为它在性能和稳定性上表现更优秀。
此外,`BeanFactoryPostProcessor`接口允许自定义扩展,如`PropertyPlaceholderConfigurer`用于处理配置文件中的占位符。 2. **工厂方法**:Spring提供的`FactoryBean`接口是工厂方法模式的体现。它使得我们能够...
- **依赖检查**:Spring可以检查应用程序中是否存在未使用的Bean引用,帮助开发者发现潜在的问题。 #### 3.4 定制Bean的行为 - **生命周期接口**:Spring定义了一系列的生命周期回调接口,如`InitializingBean`和`...
接下来,为了在Spring 4.0中引用这些属性,我们需要配置一个`PropertyPlaceholderConfigurer`或使用`@ConfigurationProperties`注解。`PropertyPlaceholderConfigurer`是Spring早期版本中用于注入properties文件中值...
下面将详细介绍如何在Spring中使用属性文件以及相关知识点。 1. **属性文件格式** 属性文件通常以`.properties`为扩展名,例如`application.properties`或`database.properties`。文件中的键值对以等号`=`分隔,如...
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <value>classpath:jdbc.properties <!-- 配置数据源 --> ${driverClassName}"/> ${url}"/> ${username...
### Spring 容器后处理器详解 #### 一、Spring 容器后处理器概念及应用...此外,使用诸如`PropertyPlaceholderConfigurer`这样的后处理器还可以提高配置管理的效率,使得应用程序能够在不同的环境中更加灵活地运行。
综上所述,Spring 2.5配置VM涉及到的是如何通过Java虚拟机参数来影响Spring应用的运行和配置,以及如何在Spring框架中使用这些参数。同时,`FormBeanUtil.java`文件可能是一个辅助工具,用于处理Spring MVC中的表单...
这个例子“基于Spring 2.0 Property Placeholder配置的源码”展示了如何在应用程序中使用Property Placeholder来动态加载和替换配置文件中的属性值,从而实现配置的灵活性和可重用性。下面将详细介绍这个主题。 1. ...