更改 Corda 中的默认 h2Port

Change default h2Port in Corda

我可以使用此默认值连接到 h2 数据库 jdbc:h2:tcp://10.0.1.6:53062/node 用于特定节点。 我想将其更改为自定义 50002。所以我在 build.gradle 文件中添加了端口,并在主文件中使用 customOverrides 启动了节点。

build.gradle 文件:

node {
    name "O=PartyA,L=London,C=GB"
    advertisedServices = []
    p2pPort 10108
    rpcPort 10109
    webPort 10110
    h2Port 50002
    cordapps = [
            "com.template:states-and-contracts:$version",
            "com.template:other-sources:$version",
            "net.corda:corda-finance:$corda_release_version"
    ]
    rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}

主文件:

startNode(providedName = CordaX500Name("PartyA", "London", "GB"), rpcUsers = listOf(user),customOverrides = mapOf("h2Port" to 50002))

但我仍然无法连接到 50002。构建后,这是配置文件结构。

node.conf 文件:

 h2port=50002
myLegalName="O=PartyA,L=New York,C=US"
networkMapService {
    address="localhost:10102"
    legalName="O=Controller,L=London,C=GB"
}
p2pAddress="localhost:10108"
rpcAddress="localhost:10109"
rpcUsers=[
    {
        password=test
        permissions=[
            ALL
        ]
        user=user1
    }
]
webAddress="localhost:10110" 

只有当我通过命令提示符 运行 时才能连接到这个端口。当我通过 intellij idea 运行 时,我遇到了这个问题。请帮忙

当通过 IntelliJ 运行 节点时,build.gradle 文件将被忽略。相反,节点是使用节点驱动程序 (https://github.com/corda/cordapp-example/blob/release-V1/kotlin-source/src/test/kotlin/com/example/NodeDriver.kt) 配置和启动的。

您可以在使用节点驱动程序时配置节点的 H2 端口,如下所示:

fun main(args: Array<String>) {
    driver {
        startNode(
            customOverrides = mapOf("h2port" to "12345")
        ).getOrThrow()
    }
}