加配置中心同理
service4.0.0 org.springframework.boot spring-boot-starter-parent2.7.2 com.xc.biz.exchange.aos demo0.0.1-SNAPSHOT demo demo 1.8 com.xc.biz.exchange.aos.Application false 8 8 1.15.1 3.5.1-1 net.devh grpc-server-spring-boot-starter2.13.1.RELEASE org.springframework.boot spring-boot-starter-weborg.springframework.boot spring-boot-starter-testtest kr.motd.maven os-maven-plugin1.6.2 org.xolstice.maven.plugins protobuf-maven-plugin0.5.1 com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} grpc-java io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} ${project.build.sourceDirectory} false compile compile-custom org.springframework.boot spring-boot-maven-plugin
server:
port: 8085
spring:
application:
name: spb-server
grpc:
server:
port: 9090
client
@GrpcService public class AOSService extends AOSServiceGrpc.AOSServiceImplBase{ @Override public void ack(AOSReq request, StreamObserver responseObserver) { AOSResp success = AOSResp.newBuilder().setCode(123).setMsg("success").build(); responseObserver.onNext(success); responseObserver.onCompleted(); } }
4.0.0 org.springframework.boot spring-boot-starter-parent2.7.2 com.xc.biz.exchange.aos demo10.0.1-SNAPSHOT demo1 demo1 1.8 com.xc.biz.exchange.aos.Application false 8 8 1.15.1 3.5.1-1 net.devh grpc-client-spring-boot-starter2.13.1.RELEASE org.springframework.boot spring-boot-starter-weborg.springframework.boot spring-boot-starter-testtest kr.motd.maven os-maven-plugin1.6.2 org.xolstice.maven.plugins protobuf-maven-plugin0.5.1 com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} grpc-java io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} ${project.build.sourceDirectory} false compile compile-custom org.springframework.boot spring-boot-maven-plugin
spring:
application:
name: spb-client
server:
port: 8086
grpc:
client:
spb-server:
address: 'static://localhost:9090'
negotiationType: PLAINTEXT
@RestController public class AOSController { @GrpcClient("spb-server") private AOSServiceGrpc.AOSServiceBlockingStub grepClient; @GetMapping("/grpc") public String test(){ AOSReq build = AOSReq.newBuilder() .setOrderId(333L) .setSuccess(true) .build(); AOSResp ack = grepClient.ack(build); return ""+ack.getCode()+ack.getMsg(); } }



