【问题标题】:Getting started with grails 3.3.9 and PostgreSQL 12.7: Error "org.postgresql.Driver"grails 3.3.9 和 PostgreSQL 12.7 入门:错误“org.postgresql.Driver”
【发布时间】:2021-07-05 22:41:25
【问题描述】:

我尝试在我的 grails 3.3.9 项目中连接一个 postgres 数据库; 我的 posgrest 服务器正在工作,因为我可以从 Intelli J 2021 数据库连接和操作 posgres 数据库,但我无法连接到 grails 3.3.9。 密码和用户是正确的,但它总是给我这个错误:

Running application...
2021-07-05 19:06:25.298 ERROR --- [           main] org.postgresql.Driver                        : Connection error: 

org.postgresql.util.PSQLException: El servidor requiere autenticación basada en  contraseña, pero no se ha provisto ninguna contraseña.

还有这个 mi Application.yml

hibernate:
   cache:
    queries: false
    use_second_level_cache: false
    use_query_cache: false

dataSource:
  IkebanaUsuarios:
    pooled: true
    jmxExport: true
    driverClassName: "org.postgresql.Driver"
    username: "postgres"
    password: "postgres"


environments:
    development:
      dataSource:
          dbCreate: update
          url: jdbc:postgresql://localhost:5432/IkebanaERP
test:
    dataSource:
        dbCreate: update
        url: jdbc:postgresql://localhost:5432/IkebanaERP
production:
    dataSource:
        dbCreate: update
        url: jdbc:postgresql://localhost:5432/IkebanaERP
        properties:
            jmxEnabled: true
            initialSize: 5
            maxActive: 50
            minIdle: 5
            maxIdle: 25
            maxWait: 10000
            maxAge: 600000
            timeBetweenEvictionRunsMillis: 5000
            minEvictableIdleTimeMillis: 60000
            validationQuery: SELECT 1
            validationQueryTimeout: 3
            validationInterval: 15000
            testOnBorrow: true
            testWhileIdle: true
            testOnReturn: false
            jdbcInterceptors: ConnectionState
            defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED

而我的 build.graddle 就是这个

.......
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.16.Final"
compile "org.grails.plugins:gsp"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.15.1"

runtime 'org.xerial:sqlite-jdbc:3.6.17'
runtime 'org.postgresql:postgresql:9.4.1208.jre1.8'
runtime 'mysql:mysql-connector-java:5.1.29'
runtime 'org.postgresql:postgresql:42.2.1.jre7'

testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.grails.plugins:geb"
testCompile "org.grails:grails-web-testing-support"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}

请帮忙;非常感谢

【问题讨论】:

    标签: database postgresql gradle grails yaml


    【解决方案1】:

    您正在为 IkebanaUsuarios 数据源定义属性,而不是为 Grails 使用的默认属性。

    你可以删除 IkebanaUsuarios 块,留下这个:

    dataSource:
        pooled: true
        jmxExport: true
        driverClassName: "org.postgresql.Driver"
        username: "postgres"
        password: "postgres"
    

    或者,如果您也需要该辅助数据源,您可以为两者定义属性。我猜你不需要它,因为你没有提到故意有两个。

    【讨论】:

    • 它的工作!!!!我在域类 Usuarios.groovy 中也有错误,其中包含“静态映射 = {datasource 'IkebanaUsuarios'}”这句话非常感谢,我最好的问候!!
    猜你喜欢
    • 2019-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-24
    • 2017-04-08
    相关资源
    最近更新 更多