2017-07-04 135 views
0

我嘗試創建gRPC客戶端。對於無法使用scala構建gRPC ManagedChannel

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文件和生成的代碼位於單獨的模塊中。

回答

0

我設法通過增加冗餘鑄造來解決這個問題

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