1、protobuf文件:
syntax = "proto2";
message MsgProto {
required int32 version = 1;
optional LineProto line = 2;
}
message LineProto {
required int32 number = 1;
repeated Line list = 3;
}
message Line {
required int32 interNr = 1;
optional int32 dirStatus = 2;
}
proto文件放在maven框架main文件夹下的与java文件夹平级下:
在这里插入图片描述
2、pom.xml文件:
<properties>
<!--grpc版本号-->
<grpc.version>1.7.0</grpc.version>
<!--protobuf 版本号-->
<protobuf.version>3.4.0</protobuf.version>
</properties>
protobuf的依赖库:
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${
protobuf.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${
grpc.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.grpc