java – 如何避免CouldNotDetermineHibernateDialectException错误?

我正在将oracle从10升级到12,对于这个特定的项目,我收到了这个错误:

<[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1460078994317> <BEA-101162> <User defined listener org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': 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 [Oracle]!.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': 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 [Oracle]!

好像它没有认识到我在DataSource上添加的配置:

dataSource {
    pooled = true
    driverClassName = "oracle.jdbc.OracleDriver"
    dialect = "org.hibernate.dialect.Oracle10gDialect"
}

我们正在使用Java 8,我们对代码有依赖性:

runtime 'com.oracle:ojdbc7:12.1.0.2'
runtime(group: 'com.oracle', name: 'ons', version: '10.2.0.3')

问题是它正在为另一个项目工作(与这个项目具有相同的结构,但由于某种原因它在这里不起作用)

是否有任何遗漏或任何我能找到问题并解决问题的方法?

最佳答案 java版本1.7.0_25发生了此问题.通过将java 1.7.0_25升级到另一个较高版本将帮助您解决问题.有时降级到1.6.X也有效.但升级是最佳解决方案.

它在Grails 2.2.3中修复.但是在Grails 2.2.3中,Linux上的OpenJDK 1.7.0_25仍然被打破,而Oracle的JDK确实可以工作.

信用额度为@ aeischeid

本教程中给出了一步一步的解决方案:
Connect Grails with Oracle 11g Example Configuration

资源链接:

> How do I avoid ‘Could not determine Hibernate dialect for database
name [H2]!’?

UPDATE

建议 – 1:

this tutorial起,我有两个建议,请试试这2个问题 –
您需要安装Grails H2 plugin.添加

compile ":h2:0.2.6"

到插件块中的grails-app / conf / BuildConfig.groovy.

建议 – 2:

在DataSource.groovy中,它们区分大小写.所以请检查是否有任何内容(如用户名或其他内容)与案例不匹配.

资源链接:MASSIVE ERROR ON GRAILS RUN-APP

建议 – 3:

danielnaber给出了一些建议
grails编译–refresh-dependencies和/或grails clean可能会有所帮助.
您将需要在grails-app / conf / DataSource.groovy中配置数据库访问(grails run-app的开发和grails war的生产)

建议 – 4:

this tutorial
删除DataSource.groovy文件并在执行grails clean后重建WAR,这将禁用基于默认文件的数据源

目前它正在尝试在文件系统上创建数据库但由于您没有权限而失败.

建议 – 5:

你可以看看https://github.com/Netflix/Lipstick/issues/8

建议 – 6:

当你在那里时,你应该修复你也看到的缓存提供程序警告 – 将hibernate块中’cache.provider_class’的值更改为

   cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider' 

请尝试6条建议.希望它可以帮到你.

点赞