日期:2014-05-20 浏览次数:20809 次
<?xml version="1.0" encoding="utf-8"?> <!-- beans是Spring配置文件的根元素,并且指定了Schema信息 --> <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.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 定义数据源Bean,使用C3P0数据源实现 com.mchange.v2.c3p0.ComboPooledDataSource--> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver" /> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/kds" /> <property name="user" value="root" /> <property name="password" value="123" /> <property name="initialPoolSize" value="10" /> <property name="minPoolSize" value="5" /> <property name="maxPoolSize" value="30" /> <property name="acquireIncrement" value="5" /> <property name="maxStatements" value="0" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="mappingResources"> <list> <value>com/kds/pojo/xml/User.hbm.xml</value> <value>com/kds/pojo/xml/Authority.hbm.xml</value> <value>com/kds/pojo/xml/Contract.hbm.xml</value> <value>com/kds/pojo/xml/Contracttype.hbm.xml</value> <value>com/kds/pojo/xml/Landmark.hbm.xml</value> <value>com/kds/pojo/xml/Orders.hbm.xml</value> <value>com/kds/pojo/xml/Product.hbm.xml</value> <value>com/kds/pojo/xml/Project.hbm.xml</value> <value> com/kds/pojo/xml/Projectuserrelation.hbm.xml</value> <value>com/kds/pojo/xml/Rightrolerelation.hbm.xml</value> <value>com/kds/pojo/xml/Role.hbm.xml</value> <value>com/kds/pojo/xml/Suit.hbm.xml</value> <value>com/kds/pojo/xml/Suitproductrelation.hbm.xml</value> <value>com/kds/pojo/xml/Suitproductrelationinorder.hbm.xml</value> <value>com/kds/pojo/xml/Task.hbm.xml</value> <value>com/kds/pojo/xml/Taskuserrelation.hbm.xml</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.generate_statistics">true</prop> <prop key="hibernate.connection.release_mode">auto</prop> <prop key="hibernate.autoReconnect">true</prop> <prop key="hibernate.show_sql">true</prop><!-- 显示sql --> <prop key="hibernate.format_sql">true</prop><!-- 将sql脚本进行进行格式化后再输出 --> </props> </property> <property name="dataSource" ref="dataSource" /> </bean> <!--设置事务管理 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!-- 配置事务的传播特性 ,指定事务管理器--> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <!-- 配置详细的事务语义 --> <tx:attributes> <tx:method name="create*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> </beans>