• spring,hibernate配置事务 beans.xml


    beans.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:context="http://www.springframework.org/schema/context"
    	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.5.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-2.5.xsd
               http://www.springframework.org/schema/aop
               http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
               http://www.springframework.org/schema/tx 
               http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    	<context:annotation-config />
    	<context:component-scan base-package="com.web" />
    	 
    	<bean id="dataSource"	class="org.apache.commons.dbcp.BasicDataSource" 	destroy-method="close">		
    		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
    		<property name="url" value="jdbc:mysql://localhost:3306/hibernatet" />
    		<property name="username" value="root" />
    		<property name="password" value="root1234" />
    	</bean>
    
    	<bean id="sessionFactory"	class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    		<property name="dataSource" ref="dataSource" />
    		<property name="annotatedClasses">
    			<list>
    				<value>com.web.model.User</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    				<prop key="hibernate.hbm2ddl.auto">update</prop>
    				<prop key="hibernate.show_sql">true</prop>
    			</props>
    		</property>
    	</bean>
    
    	<bean id="txManager"
    		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    	
    	<tx:annotation-driven transaction-manager="txManager"/>
    	<!-- 	<aop:aspectj-autoproxy proxy-target-class="true"/>  -->
    </beans>
    
  • 相关阅读:
    mysql中事务隔离级别可重复读说明
    Zookeeper安装与启动
    PHP闭包之bind和bindTo
    使用WebPack打包
    用Python下载momentum中的精美壁纸
    supervisor使用
    Shell脚本:RedisKey批量删除
    使用Certbot配置站点的https
    PHPfmt代码格式化
    创建用私钥签名的证书
  • 原文地址:https://www.cnblogs.com/wujixing/p/5761225.html
Copyright © 2020-2023  润新知