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,但接口是预期的
有谁知道如何应对这个?