spring+struts2+hibernate的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:p="http://www.springframework.org/schema/p"
       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.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop.xsd" >

<!--注释方法,自动扫描-->
<context:component-scan base-package="studentManager"/>
    <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/uplooking3?

useUnicode=true&amp;characterEncoding=utf8"/>

        <property name="user" value="root"/>
        <property name="password" value=""/>
        <!--初始化时获取的链接数 必须在minPoolSize和maxPoolsize之间-->
        <property name="initialPoolSize" value="1"/>
        <!--连接池中保留的最小连接数-->
        <property name="minPoolSize" value="1"/>
        <!--连接池中保留的最大连接数-->
        <property name="maxPoolSize" value="300"/>
        <!--空闲的最大时间,60秒内未使用,连接被丢弃 default 0表示永不丢弃-->
        <property name="maxIdleTime" value="60"/>
        <!--当连接池的连接耗尽的时候,c3p0一次同时获取的连接数 default 3-->
        <property name="acquireIncrement" value="5"/>
        <!--每60秒检查连接池中的空闲连接-->
        <property name="idleConnectionTestPeriod" value="60"/>
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingDirectoryLocations">
            <value>classpath:studentManager/hbmxml</value>

        </property>
        <!--<property name="configLocation" value="classpath:springHibernate/hibernate.cfg.xml"/>-->
        <property name="hibernateProperties">
            <value>

hibernate.dialect=org.hibernate.dialect.MySQLDialect

hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext

hibernate.hbm2ddl.auto=update

hibernate.show_sql=true

            </value>
        </property>
    </bean>
    <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <tx:annotation-driven transaction-manager="txManager"/>
</beans>