spring架构

<数据源配置Begin>

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

       <property name="locations">

            <list>

                  <value>classpath:jdbc.properties</value>

                  <value>classpath:cache.properties</value>

                  <value>classpath:config.properties</value>

           </list>

      </property>

</bean>

<bean id="basicDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

   <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>

  <property name="initialSize">

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

  </property>

  <property name="maxActive">

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

  </property>

  <property name="maxIdle">

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

  </property>

</bean>

<数据源配置End>

 

<spring事务控制Begin>

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

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

</bean>

 

<自动检测到的事物管理器使用标准名称transactionManager,因此无需显示指定transaction-manager属性>

<tx:advice id="txAdvice" transaction-manager="transactionManager">

  <tx:attributes>

    <tx:method name="add*" propagation="REQUIRED"  rollback-for="Throwable"/>

  <tx:method name="edit*" propagation="REQUIRED"  rollback-for="Throwable"/>

  <tx:method name="remove*" propagation="REQUIRED"  rollback-for="Throwable"/>

  <tx:method name="save*" propagation="REQUIRED"  rollback-for="Throwable"/>

  <tx:method name="insert*" propagation="REQUIRED"  rollback-for="Throwable"/>

  <tx:method name="delete*" propagation="REQUIRED"  rollback-for="Throwable"/>

  <tx:method name="update*" propagation="REQUIRED"  rollback-for="Throwable"/>

<tx:method name="*_TA" propagation="REQUIRED"  rollback-for="Throwable"/>

<tx:method name="*" read-only="true">

  <tx:attributes>

</tx:advice>

<aop:cofig>

 <aop:pointcut id="shoppingAllMethod" expression="(execution(* *..service.impl.*.*(..)))"/>

<aop:advisor advice-ref="txAdvice" pointcut-ref="shoppingAllMethod"/>

</aop:config>

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

<property name="configLocations">

  <list>

  <value>classpath:*.xml</value>

<value>classpath:</value>

<value>classpath:</value>

 </list

</property>

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

</bean>

 

<创建sqlMapClientTemplate>

<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">

 <constructor-arg>

  <ref bean="sqlMapClient">

</constructor-arg>

</bean>

<创建jdbcTemplate>

<bean id="jdbcTemple" class="org.springframework.jdbc.core.JdbcTemplate">

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

</bean>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值