我想在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数据库?
答案 0 :(得分: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"
]
...
}
如果您正在修改某些dataSourceProperties.{}
文件,则可以直接使用node.conf
。
此处详细介绍了整个过程:Corda with Databases other than H2
答案 1 :(得分:0)
我认为该错误描述了gradle构建失败。因此,它必须与gradle文件语法相关。只想知道是否是由于在gradle文件中的dataSourceProperties标记之后缺少了等号( = )?
还要注意,从内置资源文件中加载了一组基本的默认值 :node gradle模块的 /node/src/main/resources/reference.conf 。 dataSourceProperties标记存在于默认的参考配置集中。我们应该使用完全相同的键集(包括双引号),同时覆盖默认标记。
请通过如下方式更新build.gradle文件进行检查:
dataSourceProperties = {
dataSourceClassName = "oracle.jdbc.pool.OracleDataSource"
"dataSource.url" = "jdbc:oracle:thin:@localhost:1521:db11g2"
"dataSource.user" = "sys"
"dataSource.password" = "98765"
}