考虑在配置中定义类型为“ net.corda.core.messaging.CordaRPCOps”的bean

时间:2018-07-13 11:25:54

标签: spring webserver corda

在我的CustomController中无法使用CordaRPCOps实现方法,

@RequestMapping(value="/peers", produces = MediaType.APPLICATION_JSON)
    public Map<String, List<String>> peers() throws Exception
    {

        CordaRPCOps proxy=rpc.getParameterValue("proxy");

        Party myIdentity= proxy.nodeInfo().getLegalIdentities().get(0);

        return ImmutableMap.of("peers", rpcOpsImpl.networkMapSnapshot()
                .stream()
                .filter(nodeInfo -> nodeInfo.getLegalIdentities().get(0) != myIdentity)
                .map(it -> it.getLegalIdentities().get(0).getName().getOrganisation())
                .collect(toList()));
        }

在将runPartyAServer构建为时出错,

APPLICATION FAILED TO START

Description:

Field services in net.corda.server.controllers.CustomController required a bean of type 'net.corda.core.messaging.CordaRPCOps' that could not be found.


Action:

Consider defining a bean of type 'net.corda.core.messaging.CordaRPCOps' in your configuration.

1 个答案:

答案 0 :(得分:0)

如错误消息所述,您必须定义类型为CordaRPCConnection / CordaRPCOps的bean。

类似的东西:

@Bean
private fun connect(): CordaRPCConnection {
    val hostAndPort = NetworkHostAndPort(configuration.host, configuration.port)
    val client = CordaRPCClient(hostAndPort)
    val connection = client.start(configuration.user, configuration.password)
    return connection;
}

默认情况下,我们不提供任何DI容器集成。