Spring4+Hibernate5配置

spring4配置hibernate5:

class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
class="org.springframework.orm.hibernate5.HibernateTransactionManager">


    

    
        
        
            
                
                com.wechat.entity.po
            
        
        
            
                ${hibernate.hbm2ddl.auto}
                ${hibernate.dialect}
                ${hibernate.show_sql}
                ${hibernate.format_sql}
                false
            
        
    

    



    
        
    

    
    

    
    

    
    
    
        
        
        
        
    
    
    
        
        
            
        
    

jdbc.properties:

#-----------------------------------------------------
# 数据库配置
#-----------------------------------------------------
#服务器地址
host=127.0.0.1
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://${host}:3306/hibernate_test
jdbc.username=root
jdbc.password=root
#-----------------------------------------------------
# 适用于c3p0的配置
# c3p0反空闲设置,防止8小时失效问题28800
#-----------------------------------------------------
#idleConnectionTestPeriod要小于MySQL的wait_timeout
jdbc.c3p0.testConnectionOnCheckout=false
jdbc.c3p0.testConnectionOnCheckin=true
jdbc.c3p0.idleConnectionTestPeriod=3600
#-----------------------------------------------------
# c3p0连接池配置
#-----------------------------------------------------
#initialPoolSize, minPoolSize, maxPoolSize define the number of Connections that will be pooled.
#Please ensure that minPoolSize <= maxPoolSize.
#Unreasonable values of initialPoolSize will be ignored, and minPoolSize will be used instead.
jdbc.c3p0.initialPoolSize=10
jdbc.c3p0.minPoolSize=10
jdbc.c3p0.maxPoolSize=100
#maxIdleTime defines how many seconds a Connection should be permitted to go unused before being culled from the pool.
jdbc.c3p0.maxIdleTime=3600
#-----------------------------------------------------
# hibernate连接池配置
#-----------------------------------------------------
hibernate.connection.driverClass=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://${host}:3306/${dbName}
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.hbm2ddl.auto=update

你可能感兴趣的:(Spring4+Hibernate5配置)