日期:2014-05-16  浏览次数:20609 次

各种数据源配置之Spring+Hibernate配置DBCP数据源
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/><!-- Spring依赖注入注解功能 -->
   
    <!-- Hibernate SessionFactory -->  
<!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" autowire="autodetect">  
    <property name="mappingResources">
    <list>
    <value>cn/itcast/bean/Person.hbm.xml</value    </list>
    </property>
    <property name="hibernateProperties">
        <props>  
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
            <prop key="hibernate.connection.provider_class">com.jolbox.bonecp.provider.BoneCPConnectionProvider</prop>  
            <prop key="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</prop>  
            <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/batch?useUnicode=true&amp;characterEncoding=UTF-8</prop>  
            <prop key="hibernate.connection.username">root</prop>  
            <prop key="hibernate.connection.password">root</prop>  
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="bonecp.idleMaxAge">240</prop>
            <prop key="bonecp.idleConnectionTestPeriod">60</prop>  
            <prop key="bonecp.partitionCount">3</prop> 
            <prop key="bonecp.acquireIncrement">10</prop>  
&nb