【问题标题】:Error when add dataSourceProperties into "deployNodes"将 dataSourceProperties 添加到“deployNodes”时出错
【发布时间】:2018-09-23 19:55:01
【问题描述】:

我想在 Corda 3.1 企业版中使用 Oracle 11g 数据库设置 Corda 节点:

apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'net.corda.plugins.cordapp'
apply plugin: 'net.corda.plugins.cordformation'
apply plugin: 'net.corda.plugins.quasar-utils'
apply plugin: 'maven-publish'
jar.baseName = "cordapp-example"

task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
directory "./build/nodes"
node {
    name "O=Notary Pool,L=Sao Paolo,C=BR"
    notary = [validating : false]
    p2pPort 10002
    rpcSettings {
        address("localhost:10003")
        adminAddress("localhost:10043")
    }
    webPort 10004
    cordapps = ["$corda_release_group:corda-finance:$corda_release_version"]
    rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}
node {
    name "O=First Bank of London,L=London,C=GB"
    p2pPort 10005
    rpcSettings {
        address("localhost:10006")
        adminAddress("localhost:10046")
    }
    webPort 10007
    cordapps = ["$corda_release_group:corda-finance:$corda_release_version"]
    rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
    dataSourceProperties {
        dataSourceClassName = "oracle.jdbc.pool.OracleDataSource"
        dataSource.url = "jdbc:oracle:thin:@localhost:1521:db11g2"
        dataSource.user = "sys"
        dataSource.password = "98765"
    }
    database = {
        transactionIsolationLevel = READ_COMMITTED
        schema = "db11g2"
    }

}
}

我部署这个任务时出现错误:

 FAILURE: Build failed with an exception.

 * Where:
 Build file 'D:\WorkPlaceCorda\TestDatabase\cordapp-example\kotlin-source\build.gradle' line: 94

 * What went wrong:
 A problem occurred evaluating project ':kotlin-source'.
 Could not find method dataSourceProperties() for arguments [build_4c7s0yjnncjhr0s832fhma3b4$_run_closure6$_closure16$_closure21@45dad5d1] on object of type net.corda.plugins.Node.

那么,如何配置参数“dataSourceProperties”来连接这个节点到Oracle数据库?

【问题讨论】:

    标签: corda


    【解决方案1】:

    @Henry,为了完成您在deployNodes 任务中要做的事情,您必须使用一个名为extraConfig 的条目,如下所示:

    task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
    ...
      node {
      ...
         extraConfig = [
           "dataSourceProperties.dataSourceClassName"  = "oracle.jdbc.pool.OracleDataSource",
           "dataSourceProperties.dataSource.url"       = "jdbc:oracle:thin:@localhost:1521:db11g2",
           "dataSourceProperties.dataSource.user"      = "sys",
           "dataSourceProperties.dataSource.password"  = "98765",
           "database.transactionIsolationLevel"        = "READ_COMMITED",
           "database.schema"                           = "YOUR_DB_SCHEMA",
           "database.runMigration"                     = "true"
        ]
      ...
      }
    

    如果你正在修改一些node.conf文件,你可以直接使用dataSourceProperties.{}

    整个过程详细在这里:Corda with Databases other than H2

    【讨论】:

      【解决方案2】:

      我认为该错误描述了 gradle 构建失败。所以肯定和gradle文件语法有关。只是想知道是否是因为在您的 gradle 文件中的 dataSourceProperties 标记之后缺少等号 (=)?

      另请注意,有一组从内置资源文件加载的基本默认值 /node/src/main/resources/reference.conf :node gradle 模块。 dataSourceProperties 标记存在于默认的参考配置集中。我们应该使用完全相同的一组键(包括双引号),同时覆盖默认标记。

      请通过更新 build.gradle 文件进行检查,如下所示:

      dataSourceProperties = {
          dataSourceClassName = "oracle.jdbc.pool.OracleDataSource"
          "dataSource.url" = "jdbc:oracle:thin:@localhost:1521:db11g2"
          "dataSource.user" = "sys"
          "dataSource.password" = "98765"
      } 
      

      【讨论】:

      • 这些语句应该插入到gradle构建文件的什么位置?
      猜你喜欢
      • 1970-01-01
      • 2019-09-12
      • 2013-02-22
      • 2021-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多