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

前端之家收集整理的这篇文章主要介绍了如何避免“无法确定数据库名称的Hibernate方言[H2]!”?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
运行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.
原文链接:https://www.f2er.com/mssql/83854.html

猜你在找的MsSQL相关文章