I put generated file in api folder, since proto fils and generated files should be apis between client and server
option java_package="com.pxample.api";
//option java_multiple_files = true;
option java_outer_classname = "CityScore";
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-server-spring-boot-starter</artifactId>
<version>2.12.0.RELEASE</version>
</dependency>
@GrpcService
Annotation that marks gRPC services that should be registered with a gRPC server. If spring-boot's auto configuration is used, then the server will be created automatically. This annotation should only be added to implementations of BindableService (GrpcService-ImplBase).
The starter will add service to grpc server automatically.
<protoSourceRoot>
${basedir}/src/main/resources/proto/
</protoSourceRoot>
<outputDirectory>${basedir}/src/main/java/</outputDirectory>
<clearOutputDirectory>false</clearOutputDirectory>
The false value will not clean the generated folder when compiling the proto files.
@GrpcAdvice
public class CityScoreExceptionHandler {
@GrpcExceptionHandler(CityScoreException.class)
public StatusRuntimeException handleValidationError(CityScoreException cause) {
...
gRPC Implementation With Spring Boot
gRPC-Spring-Boot-Starter Documentation
Status codes and their use in gRPC
grpc client with springboot demo
grpc server with springboot demo
sprintboot with grpc server. Fork from nils