`

Spring 配置之 PropertyPlaceholderConfigurer

 
阅读更多

 

<!-- ============= GENERAL DEFINITIONS ============= -->

<!-- Configurer that replaces ${...} placeholders with values from a properties file -->

<!-- (in this case, JDBC-related settings for the dataSource definition below) -->

<bean id="propertyConfigurer"

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="location">

<value>classpath:spring/jdbc-oracle.properties</value>

</property>

</bean>

<!--PropertyPlaceholderConfigurer

A property resource configurer that resolves placeholders in bean property values of context definitions. It pulls values from a properties file into bean definitions

->

 

<!-- ============== RESOURCE DEFINITIONS ========= -->

<!-- Local DataSource that works in any environment -->

<bean id="dataSource"

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName">

<value>${jdbc.driverClassName}</value>

</property>

<property name="url">

<value>${jdbc.url}</value>

</property>

<property name="username">

<value>${jdbc.username}</value>

</property>

<property name="password">

<value>${jdbc.password}</value>

</property>

</bean>

<!--DriverManagerDataSource

Simple implementation of the standard JDBC DataSource interface, configuring the plain old JDBC DriverManager via bean properties, and returning a new Connection from every getConnection call. 

NOTE: This class is not an actual connection pool; it does not actually pool Connections. It just serves as simple replacement for a full-blown connection pool, implementing the same standard interface, but creating new Connections on every call

-->

 

   <!-- Spring iBatis SqlMapClient -->

    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">

        <property name="configLocation" value="classpath:ibatis/sql-map-config.xml" />

         <property name="dataSource" ref="dataSource"></property>

    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

        <property name="dataSource" ref="dataSource"></property>

    </bean>

    <bean id="transactionIterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">

     <property name="transactionManager" ref="transactionManager"></property>

     <property name="transactionAttributes">

      <props>

       <prop key="insert*">PROPAGATION_REQUIRED</prop>

       <prop key="add*">PROPAGATION_REQUIRED</prop>

       <prop key="find*,get*">PROPAGATION_REQUIRED,readOnly</prop>

       <prop key="*">PROPAGATION_REQUIRED</prop>

      </props>

     </property>

    </bean>

    <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">

     <property name="beanNames">

      <list>

       <value>*Service</value>

      </list>

     </property>

     <property name="interceptorNames">

      <list>

       <value>transactionIterceptor</value>

      </list>

     </property>

    </bean>

</beans>

分享到:
评论

相关推荐

    Spring PropertyPlaceholderConfigurer配置文件加载器集成ZooKeeper来实现远程配置读取

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

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

    在Spring3中配置数据源,包括DBCP,C3P0,Proxool,Bonecp主要的数据源,里面...&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;value&gt;classpath:proxool.properties ...

    Spring MVC 入门实例

    6 &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; 7 8 9 &lt;value&gt;/WEB-INF/jdbc.properties 10 11 12 13 14 它配置了以下功能: 读取...

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

    6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ Load-time weaving(LTW) 6.9. 其它资源 7. Spring AOP APIs 7.1. 简介 7.2. Spring中的切入点API 7.2.1. 概念 7.2.2. 切入点实施 ...

    spring.net中文手册在线版

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

    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-property-annotations:Spring 2.5.x 组件的带注释的配置属性

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

    Spring 3 Reference中文

    4.8.2.1 示例:PropertyPlaceholderConfigurer. 82 4.8.2.2 示例:PropertyOverrideConfigurer 83 4.8.3 使用FactoryBean 来自定义实例化逻辑. 84 4.9 基于注解的容器配置. 85 4.9.1 @Required....

    spring3.2+strut2+hibernate4

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

    spring3.1中文参考文档

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

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

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

    SpringEnvironmentsAndProfiles:研究如何使用Spring管理平台特定的属性文件

    与通过从属性文件读取其配置来进行自我配置相比,对于应用程序而言,有什么可能更简单? 好吧,对于业务应用程序而言,事实并非如此简单! 出现的问题如下:0.如何根据执行平台读取不同的属性? 0.如何保护敏感值,...

    SSI框架整合实例

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

    springmvcmybatis

    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;!-- ${jdbc.driver}" /&gt; ${jdbc.url}" /&gt; ${jdbc.username}" /&gt; ${jdbc.password}" /&gt; 初始化连接大小 ...

Global site tag (gtag.js) - Google Analytics