加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

如何避免“无法确定数据库名称的Hibernate方言[H2]

发布时间:2021-01-26 05:28:07 所属栏目:MsSql教程 来源:网络整理
导读:运行grails run-app时出现此错误: Error executing bootstraps: Error creating bean with name ‘messageSource’: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean wi

运行grails run-app时出现此错误:

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)时,会发生以下错误:

执行bootstraps时出错:创建名为’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,但接口是预期的

有谁知道如何应对这个?

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

解决方法

这是Joda Time Plugin中的一个错误.有关详细信息,请参阅上述 JIRA issue.

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读