2010-08-29 184 views
3

這裏是我的hibernate配置,但由於某些原因,它無法加載我已經添加到<property name="hibernateProperties">的那些屬性,並且日誌在啓動時說明INFO org.hibernate.cfg.Environment - hibernate.properties not foundSpring和Hibernate配置

<?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: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-3.0.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-3.0.xsd"> 

    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"> 
     <property name="driverClassName" value="org.hibernate.dialect.PostgreSQLDialect" /> 
     <property name="url" value="jdbc:postgresql://localhost:5432/testdatabase" /> 
     <property name="username" value="postgres" /> 
     <property name="password" value="password" /> 
    </bean> 

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
     <property name="dataSource" ref="myDataSource" /> 
     <property name="packagesToScan" value="org.test"/> 
     <property name="hibernateProperties"> 
      <value> 
       hbm2ddl.auto=create 
       hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect 
       hibernate.show_sql=true    
      </value> 
     </property> 
    </bean> 

    <bean id="transactionManager" 
     class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
     <property name="sessionFactory" ref="sessionFactory" /> 
    </bean> 

</beans> 

編輯:完整的日誌:

2010-08-29 15:27:15,986 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.3.1.GA 
    2010-08-29 15:27:15,997 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.2.6 
    2010-08-29 15:27:16,000 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 
    2010-08-29 15:27:16,002 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : cglib 
    2010-08-29 15:27:16,005 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 
    2010-08-29 15:27:16,113 [main] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: org.test.TestEntity 
    2010-08-29 15:27:16,145 [main] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity org.test.TestEntity on table TestEntity 
    2010-08-29 15:27:16,188 [main] INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring 
    2010-08-29 15:27:16,188 [main] INFO org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean - Building new Hibernate SessionFactory 
    2010-08-29 15:27:16,238 [main] INFO org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider 
    2010-08-29 15:27:16,663 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: PostgreSQL, version: 9.0beta4 
    2010-08-29 15:27:16,664 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.3 JDBC3 with SSL (build 603) 
    2010-08-29 15:27:16,667 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect 
    2010-08-29 15:27:16,672 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory 
    2010-08-29 15:27:16,674 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 
    2010-08-29 15:27:16,674 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled 
    2010-08-29 15:27:16,674 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled 
    2010-08-29 15:27:16,674 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15 
    2010-08-29 15:27:16,674 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled 
    2010-08-29 15:27:16,675 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled 
    2010-08-29 15:27:16,675 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled 
    2010-08-29 15:27:16,675 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto 
    2010-08-29 15:27:16,675 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1 
    2010-08-29 15:27:16,675 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled 
    2010-08-29 15:27:16,676 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled 
    2010-08-29 15:27:16,676 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled 
    2010-08-29 15:27:16,676 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 
    2010-08-29 15:27:16,678 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory 
    2010-08-29 15:27:16,678 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {} 
    2010-08-29 15:27:16,678 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled 
    2010-08-29 15:27:16,678 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled 
    2010-08-29 15:27:16,678 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled 
    2010-08-29 15:27:16,678 [main] INFO org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.NoCacheProvider 
    2010-08-29 15:27:16,678 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled 
    2010-08-29 15:27:16,678 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled 
    2010-08-29 15:27:16,683 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout 
    2010-08-29 15:27:16,683 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled 
    2010-08-29 15:27:16,683 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled 
    2010-08-29 15:27:16,684 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo 
    2010-08-29 15:27:16,684 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled 
    2010-08-29 15:27:16,703 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory 
    2010-08-29 15:27:16,888 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured 
2010-08-29 15:27:17,096 [main] INFO org.springframework.orm.hibernate3.HibernateTransactionManager - Using DataSource [[email protected]] of Hibernate SessionFactory for HibernateTransactionManager 
+0

請向我們展示了充滿春天/休眠啓動日誌,不只是線 – skaffman 2010-08-29 12:44:42

回答

5

我認爲hibernateProperties越來越設置錯誤(除非Spring有設置,我不知道性能的新方法)。通常屬性手動設置是這樣的:

<property name="hibernateProperties"> 
     <props> 
      <prop key="hbm2ddl.auto">create</prop> 
      <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> 
      <prop key="hibernate.show_sql">true</prop> 
     </props> 
    </property> 

另一種方式(我喜歡)只是在hibernate.properties文件堅持這些屬性,然後把該文件在classpath的根目錄下。這可能是錯誤信息所指的。

0

要設置在driverClassName方言這是不對得到的lib文件的jar在postgre安裝文件夾的jdbc驅動