我正在使用 gRPC 应用程序并构建一个简单的应用程序。在文件下面。
syntax = "proto3";
option java_multiple_files = true;
package com.grpc;
message HelloRequest {
string firstName = 1;
string lastname = 2;
}
message HelloResponse {
string greeting = 1;
}
service HelloService {
rpc hello(HelloRequest) returns (HelloResponse);
}
Run Code Online (Sandbox Code Playgroud)
它正常生成文件
User.java -> generated from protoc compiler
userGrpc.java -> generated from protoc compiler
Run Code Online (Sandbox Code Playgroud)
GRPC服务.java
package GRPCService;
import java.io.IOException;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import user.UserService;
public class GPRCService {
public static void main(String[] args) throws IOException, InterruptedException {
Server server = …Run Code Online (Sandbox Code Playgroud)