首页 > 解决方案 > 如何将 postgres 配置添加到 cordas build gradle deployNodes-task

问题描述

我想在 build-gradle 任务deployNodes中将默认 h2-database 的配置替换为 postgres 实现

我想替换条目h2Port 10013

dataSourceProperties: {
    dataSourceClassName: "org.postgresql.ds.PGSimpleDataSource",
    dataSource.url: "jdbc:postgresql://localhost:5432/postgres_xyz?currentSchema=public",
    dataSource.user: "xyz",
    dataSource.password: "xyz",
    dataSource.currentSchema: "public"
}
database: {
    transactionIsolationLevel: "READ_COMMITTED"
}

我该怎么做/我可以使用哪种格式?

标签: postgresqlgradlecorda

解决方案


build.gradle您可以使用块在脚本中将 Postgresql DB 属性添加到您的节点配置中extraConfig=[ ... ],如下所示。

node {

    ...

    extraConfig = [
        dataSourceProperties: [
                dataSourceClassName : "org.postgresql.ds.PGSimpleDataSource",
                'dataSource.url' : "jdbc:postgresql://localhost:5432/nodedb",
                'dataSource.user' : "postgres",
                'dataSource.password' : "pa$$w0rd"
        ],
        database: [
                transactionIsolationLevel : "READ_COMMITTED"
        ]
    ]
}

推荐阅读