1

postgresql で grails アプリケーションを開発しようとしています。設定は次のとおりです。

Ubuntu 12.04

グレイル 2.3.1

Maven 以外のプロジェクトを開発したい。grails create-app コマンドでアプリケーションを作成し、MVC を作成しましたが、正常に動作しています。

次に、postgresql を使用するために、Datasource.groovy を次のように編集しました。

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"
        }
    }
}

次のように BuildConf.groovy の plugins セクションに postgresql を追加しました。

 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"
    }

アプリケーションを実行すると、次のエラーが表示されます。

grails> アプリの実行 | Error Error running script run-app: _GrailsInit_groovy$_run_closure1_closure6 (完全なトレースを表示するには --stacktrace を使用してください)

グレイルズ>

私は何を間違っていますか?

同じセットアップで、この例に従ってもう 1 つのプロジェクトを作成したことに注意してください (例で指定されている他のデータベースの代わりに postgresql を使用しています)。正常に動作しています。サンプル プロジェクトと私の唯一の違いは、サンプル プロジェクトが intellij ( grails integrate-with --intellij) と統合されており、私のプロジェクトでは intellij と統合していないことです。

4

1 に答える 1

1

The plugins block is used just for Grails plugins. For jar dependencies you need to use the dependencies block.

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