Grails postgresql数据库连接

时间:2014-10-30 22:23:16

标签: grails

刚开始Grails。经历了所有问题,但仍然存在问题。 连接器似乎到位。 jdbc connector in the lib folder and dependency added to a class path

BuildConfig的存储库

 repositories {
    inherits true // Whether to inherit repository definitions from plugins

    grailsPlugins()
    grailsHome()
    mavenLocal()
    grailsCentral()
    mavenCentral()
    // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
    //mavenRepo "http://repository.codehaus.org"
    //mavenRepo "http://download.java.net/maven/2/"
    //mavenRepo "http://repository.jboss.com/maven2/"
    //mavenRepo "http://repo1.maven.org/maven2/"
}

数据源

dataSource {
    pooled = true
    jmxExport = true
    driverClassName = "org.postgresql.Driver"
    username = "postgres"
    password = "password"
}

environments {
    development {
        dataSource {
        dbCreate = "update"
        url = "jdbc:postgresql://localhost:5433/dev1base"
    }
}

我明白了:

|Loading Grails 2.4.3
|Configuring classpath
Error |
Resolve error obtaining dependencies: Could not find artifact postgresql:postgresql:jar:9.3-  1100.jdbc4 in grailsCentral (http://repo.grails.org/grails/plugins) (Use --stacktrace to see the full trace)
Error |
Resolve error obtaining dependencies: Could not find artifact postgresql:postgresql:jar:9.3-1100.jdbc4 in grailsCentral (http://repo.grails.org/grails/plugins) (Use --stacktrace to see the full trace)
Error |
Could not find artifact postgresql:postgresql:jar:9.3-1100.jdbc4 in grailsCentral (http://repo.grails.org/grails/plugins)
|Run 'grails dependency-report' for further information.

这里不应该是魔术。

2 个答案:

答案 0 :(得分:3)

问题在于工件的格式化。它应该是:

runtime 'org.postgresql:postgresql:9.3-1100-jdbc41'

请注意,最后一段时间应该是破折号。

答案 1 :(得分:1)

Config.groovy中添加依赖项:

dependencies {
    runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'

这是我正在使用的版本,但您可以先尝试使用您的版本(请注意格式:添加'组织'前缀并替换'。'与& #39; - &#39)。更近期的版本1102似乎也可用(http://mvnrepository.com/artifact/org.postgresql/postgresql