- <?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" xmlns:p="http://www.springframework.org/schema/p" 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:component-scan base-package="cn.ibook" />
- - <bean name="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/Ibook?useUnicode=true&characterEncoding=UTF-8" />
- <property name="user" value="root" />
- <property name="password" value="123xf" />
- <property name="initialPoolSize" value="1" />
- <property name="minPoolSize" value="1" />
- <property name="maxPoolSize" value="300" />
- <property name="maxIdleTime" value="60" />
- <property name="acquireIncrement" value="5" />
- <property name="idleConnectionTestPeriod" value="60" />
- </bean>
- - <bean name="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="dataSource" ref="dataSource" />
- - <property name="mappingResources">
- - <list>
- <value>cn/ibook/bbs/bean/Article.hbm.xml</value>
- <value>cn/ibook/bbs/bean/Attachment.hbm.xml</value>
- <value>cn/ibook/bbs/bean/Category.hbm.xml</value>
- <value>cn/ibook/bbs/bean/Forum.hbm.xml</value>
- <value>cn/ibook/bbs/bean/Role.hbm.xml</value>
- <value>cn/ibook/bbs/bean/SystemPrivilege.hbm.xml</value>
- <value>cn/ibook/bbs/bean/User.hbm.xml</value>
- </list>
- </property>
- - <property name="hibernateProperties">
- <value>hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.hbm2ddl.auto=update hibernate.show_sql=true hibernate.format_sql=true hibernate.cache.use_second_level_cache=true hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider</value>
- </property>
- </bean>
- - <!-- 配置Hibernate的局部事务管理器,使用HibernateTransactionManager类
- -->
- - <!-- 该类实现PlatformTransactionManager接口,是针对Hibernate的特定实现
- -->
- - <!-- 并注入SessionFactory的引用
- -->
- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" />
- - <!-- 配置事务增强处理Bean,指定事务管理器
- -->
- - <tx:advice id="txAdvice" transaction-manager="transactionManager">
- - <!-- 用于配置详细的事务语义
- -->
- - <tx:attributes>
- - <!-- 所有以'get'开头的方法是read-only的
- -->
- <tx:method name="get*" read-only="true" />
- - <!-- 其他方法使用默认的事务设置
- -->
- <tx:method name="*" />
- </tx:attributes>
- </tx:advice>
- </beans>
复制代码 |