SSH中的spring配置文件

applicationContext-db.xml

 <bean id="commonOnlDAO" class="dap.dao.BaseDAO">
  <property name="sessionFactory">
   <ref bean="onlSessionFactory" />   
  </property>
 </bean> 


 <bean id="commonHisDAO" class="dap.dao.BaseDAO">
  <property name="sessionFactory">
   <ref bean="hisSessionFactory" />   
  </property>
 </bean> 

两个DAO的定义,通常声明DAO的时候,都是用接口来声明来使spring注入


 <bean id="txn1001BO" name="txn1001BO" class="dap.service.bo.validate.impl.AuthReqBOImpl" scope="prototype">
  <property name="commonOnlDAO" ref="commonOnlDAO"/>
  <property name="commonHisDAO" ref="commonHisDAO"/>定义bo层的操作时,需要注入的DAO定义
 </bean>


 <!-- 历史库数据源-->
 <bean id="hisDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  <property name="driverClass" value="${dapHis.connection.driver_class}"/>
  <property name="jdbcUrl" value="${dapHis.connection.url}"/>
  <property name="idleConnectionTestPeriod" value="${dapHis.pool.c3p0.idle_connection_test_period}" />
  <property name="properties">
   <props>
    <prop key="user">${dapHis.connection.username}</prop>
    <prop key="password">${dapHis.connection.password}</prop>
    <prop key="acquireIncrement">${dapHis.pool.c3p0.acquire_increment}</prop>
    <prop key="maxPoolSize">${dapHis.pool.c3p0.max_size}</prop>
    <prop key="minPoolSize">${dapHis.pool.c3p0.min_size}</prop>
    <prop key="checkoutTimeout">3000</prop>
   </props>
  </property>
 </bean> 
 <!-- 在线库数据源 -->
 <bean id="onlDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  <property name="driverClass" value="${dapOnl.connection.driver_class}"/>
  <property name="jdbcUrl" value="${dapOnl.connection.url}"/>
  <property name="idleConnectionTestPeriod" value="${dapOnl.pool.c3p0.idle_connection_test_period}" />
  <property name="properties">
   <props>
    <prop key="user">${dapOnl.connection.username}</prop>
    <prop key="password">${dapOnl.connection.password}</prop>
    <prop key="acquireIncrement">${dapOnl.pool.c3p0.acquire_increment}</prop>
    <prop key="maxPoolSize">${dapOnl.pool.c3p0.max_size}</prop>
    <prop key="minPoolSize">${dapOnl.pool.c3p0.min_size}</prop>
    <prop key="checkoutTimeout">3000</prop>
   </props>
  </property>
 </bean> 

 <bean id="hisTransactionManager"历史库的事务处理声明 class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref local="hisSessionFactory"/>
  </property>
 </bean>
 <bean id="onlTransactionManager"在线库的事务处理声明 class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref local="onlSessionFactory"/>
  </property>
 </bean>

 <bean id="system.onlTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
  <property name="transactionManager">在线库的事务处理声明
   <ref bean="onlTransactionManager" />
  </property>
  <property name="transactionAttributes">
   <props>
    <prop key="*">PROPAGATION_SUPPORTS,-java.lang.Exception</prop>
    <prop key="execut*">PROPAGATION_REQUIRED,-java.lang.Exception</prop>

处理所有execut开头的方法,如果报Exception错误就回滚。(+意思就是不回滚)
   </props>
  </property>
 </bean>  
 <bean id="system.hisTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
  <property name="transactionManager">历史库的事务拦截器
   <ref bean="hisTransactionManager" />
  </property>
  <property name="transactionAttributes">
   <props>
    <prop key="*">PROPAGATION_SUPPORTS,-java.lang.Exception</prop>
    <prop key="execut*">PROPAGATION_REQUIRED,-java.lang.Exception</prop>
    <!--<prop key="load*">PROPAGATION_SUPPORTS,readOnly</prop>-->
   </props>
  </property>
 </bean>  
 
 <bean id="onlSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource">
   <ref local="onlDataSource"/>
  </property>
  <property name="mappingResources">
   <list>
    <value>hbm/TblDapTxnLog.hbm.xml</value>
   </list>
  </property>
  <property name="hibernateProperties">
   <props>
    <!-- 方言 -->
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    <!-- 在log和console中打印出更漂亮的SQL  -->
    <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
    <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
    <prop key="hibernate.default_batch_fetch_size">16</prop>
    <prop key="hibernate.jdbc.fetch_size">50</prop>
    <prop key="hibernate.jdbc.batch_size">30</prop>
    <prop key="hibernate.cache.use_query_cache">false</prop>
    <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
    <prop key="hibernate.max_fetch_depth">${hibernate.max_fetch_depth}</prop>
   </props>
  </property>
 </bean> 
 <bean id="hisSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource">
   <ref local="hisDataSource"/>
  </property>
  <property name="mappingResources">
   <list>
    <value>hbm/TblDapBlackCardInfo.hbm.xml</value>生成的类所对应的表一定要有主键
    <value>hbm/TblDapCardInfo.hbm.xml</value>
    <value>hbm/TblDapInstInfo.hbm.xml</value>
    <value>hbm/TblDapSysParam.hbm.xml</value>
    <value>hbm/TblDapUserCardMap.hbm.xml</value>
    <value>hbm/TblDapUsrExtInfo.hbm.xml</value>
   </list>
  </property>
  <property name="hibernateProperties">
   <props>
    <!-- 方言 -->
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    <!-- 在log和console中打印出更漂亮的SQL  -->
    <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
    <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
    <prop key="hibernate.default_batch_fetch_size">16</prop>
    <prop key="hibernate.jdbc.fetch_size">50</prop>
    <prop key="hibernate.jdbc.batch_size">30</prop>
    <prop key="hibernate.cache.use_query_cache">false</prop>
    <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
    <prop key="hibernate.max_fetch_depth">${hibernate.max_fetch_depth}</prop>
   </props>
  </property>
 </bean> 


 <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
  <!--<property name="proxyTargetClass" value="true" />-->

当value="false"时,不能用类来声明需要注入的数据,一定要用接口来声明
  <property name="beanNames">
   <list>
    <value>*BO</value>处理以BO结尾的bean,对应bo层的方法
   </list>
  </property>
  <property name="interceptorNames">
   <list>
    <value>system.onlTransactionInterceptor</value>拦截器的名字一定要唯一
    <value>system.hisTransactionInterceptor</value>
   </list>
  </property>
 </bean>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值