我如何避免“无法确定Hibernate方言数据库名称[H2]!'? [英] How do I avoid 'Could not determine Hibernate dialect for database name [H2]!'?

查看:160
本文介绍了我如何避免“无法确定Hibernate方言数据库名称[H2]!'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 grails run-app 时遇到此错误:


执行引导程序时出错:创建名为$ b的bean时出错:$ b'messageSource':初始化bean失败;嵌套异常是
org.springframework.beans.factory.BeanCreationException:错误
创建名为'transactionManager'的bean:设置bean属性'sessionFactory'时,无法将引用
解析为bean'sessionFactory'
嵌套异常是
org.springframework.beans.factory.BeanCreationException:错误
创建名为'sessionFactory'的bean:设置bean属性时无法解析对
bean'hibernateProperties'的引用
'hibernateProperties';嵌套异常是
org.springframework.beans.factory.BeanCreationException:错误
创建名为'hibernateProperties'的bean:在设置bean属性
时无法解析
对bean'dialectDetector'的引用'properties'with key [hibernate.dialect];嵌套异常是
org.springframework.beans.factory.BeanCreationException:错误
创建名为'dialectDetector'的bean:调用init方法
失败;嵌套异常是
org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException:
无法为数据库名称[H2]确定Hibernate方言!

Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!

根据 DataSource.groovy

dataSource {
  pooled = true
  driverClassName = "org.h2.Driver"
  username = "sa"
  password = ""
  // Adding this causes a different error:
  // dialect = org.hibernate.dialect.H2Dialect
}

hibernate {
  cache.use_second_level_cache = true
  cache.use_query_cache = true
  cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}

environments {
  development {
    dataSource {
      dbCreate = "create-drop" // one of 'create', 'create-drop','update'
      url = "jdbc:h2:mem:devDB"
    }
  }
  test { // test-related stuff }
  production { // prod-related stuff }
}

当我明确提供如上所述的方言 org.hibernate.dialect.H2Dialect )时,发生:

执行引导程序时出错:创建名为'messageSource'的bean时出错:bean初始化失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为transactionManager的bean时出错:在设置bean属性sessionFactory时无法解析对bean'sessionFactory'的引用。嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:调用init方法失败;嵌套异常是java.lang.IncompatibleClassChangeError:找到类org.hibernate.cfg.Mappings,但需要接口

Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Found class org.hibernate.cfg.Mappings, but interface was expected

任何人都知道如何处理这个问题? / strong>

Anyone know how to cope with this?

(错误报告存在 http://jira.grails.org/browse/GRAILS-7994

推荐答案

这是一个错误在Joda时间插件。有关详情,请参阅提到的 JIRA问题

This was a bug in the Joda Time Plugin. See the mentioned JIRA issue for details.

这篇关于我如何避免“无法确定Hibernate方言数据库名称[H2]!'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆