Gradle / Grails gradle grails-run-app命令失败

时间:2013-12-19 03:28:55

标签: grails gradle

我使用下面的gradle构建脚本来测试示例应用程序。

使用此脚本运行gradle init命令,然后

  

gradle grails-run-app

命令它编译但失败了这条消息。 “无法确定Hibernate方言的数据库名称[H2]!”

Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreat
ionException: 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 'hibernateProper
ties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hib
ernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.spr
ingframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.gr
oovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!

但如果我运行grails run-app,它就可以了。看起来gradle.build文件中缺少某些东西。你能帮我解决这个错误信息吗?

gradle -v

------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------

Build time:   2013-12-17 09:28:15 UTC
Build number: none
Revision:     36ced393628875ff15575fa03d16c1349ffe8bb6

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.6.0_24 (Sun Microsystems Inc. 20.0-b12)
OS:           Linux 2.6.32-358.23.2.el6.i686 i386

构建脚本:

 cat build.gradle
buildscript {
        repositories {
            mavenCentral()
            maven { url 'http://repo.grails.org/grails/repo' }
        }
        dependencies {
            classpath "org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT"
        }
}
repositories {
    mavenCentral()
    maven { url 'http://repo.grails.org/grails/repo'  }
}
version = "1.0"
apply plugin: "grails"
apply plugin: 'idea'
grails {
  grailsVersion = "2.3.4"
}
dependencies {
    ['dependencies', 'core', 'spring', 'web', 'plugin-datasource', 'plugin-domain-class', 'plugin-controllers', 'plugin-services'].each { plugin ->
        compile "org.grails:grails-$plugin:2.3.2"
    }
    compile 'org.grails.plugins:tomcat:7.0.47'
    compile 'org.grails.plugins:hibernate:3.6.10.6'
    compile 'com.h2database:h2:1.3.173'
    bootstrap "org.codehaus.groovy:groovy-all:2.1.9"
}

1 个答案:

答案 0 :(得分:0)

我认为您没有在MySQL WorkBench中创建新架构。创建新的架构名称,例如在DataSource.groovy中     文件