我尝试创建一个gRPC客户端。对于

val channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext(true).build


我收到此编译时错误

Error:(18, 87) value build is not a member of ?0
    val channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext(true).build


gRPC是为Java构建的。我的项目是多模块Maven项目,其中protobuf文件和生成的代码在单独的模块中。

最佳答案

我设法通过添加多余的投射解决了这个问题

 val channel = ManagedChannelBuilder
    .forAddress(host, port)
    .usePlaintext(true)
    .asInstanceOf[ManagedChannelBuilder[_]].build

07-28 02:31
查看更多