`
rubyq
  • 浏览: 81939 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

Spring框架中的PropertyPlaceholderConfigurer类

阅读更多
Spring框架中的PropertyPlaceholderConfigurer类

PropertyPlaceholderConfigurer类可以在applicationContext.xml配置文件中加入一个或者多个外部属性文件properties(注意location和locations属性):

<!-- 一个外部文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="location" value="classpath:/conf/jdbc-mysql.properties"/>
</bean>

<!-- 多个外部文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="locations">
<list>
   <value>classpath*:/conf/jdbc-mysql.properties</value>     <value>classpath*:/conf/hibernate-mysql.properties</value>
</list>
      </property>
</bean>
<!--引用外部文件属性用${key}-->
<bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${c3p0.driverClassName}" />
<property name="jdbcUrl" value="${c3p0.jdbcUrl}" />
        <property name="user" value="${c3p0.user}" />
        <property name="password" value="${c3p0.password}" />
        <property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
        <property name="minPoolSize" value="${c3p0.minPoolSize}" />
        <property name="initialPoolSize" value="${c3p0.initialPoolSize}" />
        <property name="breakAfterAcquireFailure" value="${c3p0.breakAfterAcquireFailure}" />
</bean>
分享到:
评论

相关推荐

    Spring中PropertyPlaceholderConfigurer的使用

    PropertyPlaceholderConfigurer 是 Spring 框架中的一个重要组件,用于加载和管理 Properties 文件。它能够将 Properties 文件中的键值对注入到 Spring 的 bean 中,从而实现了配置的外部化和动态化。 基本使用方法...

    Spring属性占位符PropertyPlaceholderConfigurer的使用

    Spring属性占位符PropertyPlaceholderConfigurer的使用,自己写的一个demo

    Spring如何使用PropertyPlaceholderConfigurer读取文件

    主要介绍了Spring如何使用PropertyPlaceholderConfigurer读取文件,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

    开源框架 Spring Gossip

    第一个 Struts 程式 在 Struts 中整合 Spring 第一个 JSF 程式 在 JSF 中整合 Spring &lt;br&gt; 其它 Spring 提供了简化且一致的方式,让您在使用一些 API 或服务时更加简单。 远程...

    Spring-Reference_zh_CN(Spring中文参考手册)

    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配置文件加载器集成ZooKeeper来实现远程配置读取

    NULL 博文链接:https://wokeke.iteye.com/blog/2214113

    spring.net中文手册在线版

    Spring.NET是一个应用程序框架,其目的是协助开发人员创建企业级的.NET应用程序。它提供了很多方面的功能,比如依赖注入、面向方面编程(AOP)、数据访问抽象及ASP.NET扩展等等。Spring.NET以Java版的Spring框架为...

    Spring MVC 入门实例

    这篇文章将教你快速地上手使用 Spring 框架. 如果你手上有一本《Spring in Action》, 那么你最好从第三部分"Spring 在 Web 层的应用--建立 Web 层"开始看, 否则那将是一场恶梦! 首先, 我需要在你心里建立起 Spring...

    spring3.1中文参考文档

    spring3.1中文参考文档,南磊翻译,现在有4章,目录如下: 第一部分 Spring framework概述.......................................................................................................................

    org.springframework.beans.factory.config.PropertyPlaceholderConfigurer

    NULL 博文链接:https://chyy001.iteye.com/blog/1338488

    Spring3中配置DBCP,C3P0,Proxool,Bonecp数据源

    Spring中的配置信息 &lt;?xml version="1.0" encoding="UTF-8"?&gt; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop=...

    Spring 3 Reference中文

    4.6.1.6 在非Web 应用中,优雅地关闭Spring IoC 容器 74 4.6.2 ApplicationContextAware 和BeanNameAware . 75 4.6.3 其它Aware 接口 75 4.7 Bean 定义的继承. 77 4.8 容器扩展点. 78 4.8.1...

    spring-property-annotations:Spring 2.5.x 组件的带注释的配置属性

    #Spring 属性注释扩展的 PropertyPlaceHolderConfigurer 使用注解将配置属性注入到 Spring 组件中。 注意:Spring 3 现在支持使用 @Value 注释的容器的。 该项目仅用于 Spring 2.5.x 支持。 ##入门Spring房产注解...

    SSI框架整合实例

    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;value&gt;classpath:jdbc.properties ${driver}"/&gt; ${url}"/&gt; ${username}"/&gt; ${password}"/&gt; &lt;!-- 配置...

    ssh框架在application.xml中配置数据源所需jar

    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;value&gt;classpath:/deploy.properties &lt;!-- 配置sessionFactory ...

    SPRING API 2.0.CHM

    PropertyPlaceholderConfigurer PropertyResourceConfigurer PropertyValue PropertyValues PropertyValuesEditor PrototypeAspectInstanceFactory PrototypeTargetSource ProxyConfig ProxyFactory ...

    Spring + Hibernate + Struts 事务配置小例子(带提示框等小技巧)

    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;value&gt;WEB-INF/jdbc.properties class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-...

    spring-framework-reference-4.1.2

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    spring3.2+strut2+hibernate4

    &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;value&gt;classpath*:jdbc.properties &lt;!-- 数据源配置,主要用于开发测试...

Global site tag (gtag.js) - Google Analytics