1

I am trying to develop grails application with postgresql. The settings are as follows:

Ubuntu 12.04

Grails 2.3.1

I want to develop non-maven project. I created application with grails create-app command and then created MVC, which is working fine.

Then, to use postgresql, I edited Datasource.groovy as follows:

dataSource {
    pooled = true
    driverClassName = "org.postgresql.Driver"
    username = "grails"
    password = "grails"
}
hibernate {
    cache.use_second_level_cache=true
    cache.use_query_cache=true
    cache.provider_class='org.hibernate.cache.EhCacheProvider'
}
// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "update" // one of 'create', 'create-drop','update'
            url = "jdbc:postgresql://localhost:5432/grails"
        }
    }
    test {
        dataSource {
            dbCreate = "update"
            url = "jdbc:postgresql://localhost:5432/grails"
        }
    }
    production {
        dataSource {
            dbCreate = "update"
            url = "jdbc:postgresql://localhost:5432/grails"
        }
    }
}

and added postgresql in plugins section of BuildConf.groovy as follows:

 plugins {
        // plugins for the build system only
        build ":tomcat:7.0.42"

        // plugins for the compile step
        compile ":scaffolding:2.0.1"
        compile ':cache:1.1.1'

        // plugins needed at runtime but not for compilation
        runtime ":hibernate:3.6.10.2" // or ":hibernate4:4.1.11.2"
        runtime ":database-migration:1.3.5"
        runtime ":jquery:1.10.2"
        runtime ":resources:1.2.1"
        // Uncomment these (or add new ones) to enable additional resources capabilities
        //runtime ":zipped-resources:1.0.1"
        //runtime ":cached-resources:1.1"
        //runtime ":yui-minify-resources:0.1.5"
        runtime  "postgresql:postgresql:9.2-1003.jdbc3"
    }

When, I run the application I am getting the following error:

grails> run-app | Error Error running script run-app: _GrailsInit_groovy$_run_closure1_closure6 (Use --stacktrace to see the full trace)

grails>

What am I doing wrong ?

Note, with the same set-up I created one more project following this example (and using postgresql instead of other db specified in the example) , and it is working fine. The only difference between the example project and mine, is that the example project is integraged with intellij (grails integrate-with --intellij) and in my project I have NOT integrated with intellij.

4

1 回答 1

1

plugins块仅用于 Grails 插件。对于 jar 依赖项,您需要使用该dependencies块。

dependencies {
  runtime  "postgresql:postgresql:9.2-1003.jdbc3"
}
于 2013-10-29T12:36:50.727 回答