SSH结合spring事务管理配置文件

来源:互联网 发布:loading windows files 编辑:程序博客网 时间:2024/05/29 04:26

applicationContext.xml文件

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"><!-- To provide a placeholder, mainly for database configuration --> <bean id="propertyConfigure" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">      <property name="locations">        <list>        <value>classpath:resource/properties/dbconfig.properties</value>        </list>     </property>  </bean>      <!--Database connection pool configuration -->    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">      <property name="driverClass">            <value>${jdbc.driverClassName}</value>      </property>      <property name="jdbcUrl">      <value>${jdbc.url}</value>      </property>      <property name="user">      <value>${jdbc.username}</value>      </property>      <property name="password">      <value>${jdbc.password}</value>      </property>    </bean>    <!-- Hibernate SessionFactory configuration --><bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop>                  <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>                <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>                <prop key="hibernate.jdbc.batch_size">50</prop><prop key="hibernate.connection.autocommit">true</prop> <!-- 下面这句是映射数据库字段clob为String --><prop key="hibernate.connection.SetBigStringTryClob">true</prop></props></property>        <!-- 采用xml配置文件方式 --><property name="mappingResources"><list><value>com/*.hbm.xml</value></list></property><!-- 采用注解方式的model --><!--<property name="annotatedClasses"><list></list></property>--></bean><!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --><bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory"></property></bean><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes>          <tx:method name="add*" propagation="REQUIRED"  />          <tx:method name="save*" propagation="REQUIRED"  />          <tx:method name="insert*" propagation="REQUIRED"  />          <tx:method name="delete*" propagation="REQUIRED"  />          <tx:method name="edit*" propagation="REQUIRED" />         <tx:method name="update*" propagation="REQUIRED"  />           <tx:method name="monitor*" propagation="REQUIRED" />        <tx:method name="*" read-only="true"/>      </tx:attributes>  </tx:advice><!--transaction path config--><aop:config>      <aop:pointcut id="allManagerMethod" expression="execution(* com.*.*.service.*.*(..))"/>      <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>  </aop:config>    </beans>




原创粉丝点击