- Add dependencies (see examples)
ru.alfalab.grpc.spring:starter
io.grpc:grpc-stub
io.grpc:grpc-protobuf
io.grpc:grpc-netty
example:
repositories {
jcenter()
}
apply plugin: 'java'
apply plugin: 'com.google.protobuf'
apply plugin: 'org.springframework.boot'
dependencies {
compile "ru.alfalab.grpc.spring:starter:$starterVersion"
compile "io.grpc:grpc-stub:$grpcVersion"
compile "io.grpc:grpc-protobuf:$grpcVersion"
compile "io.grpc:grpc-netty:$grpcVersion"
}
// see examples/example-isolated/build.gradle for details - Add
@EnableGRpcServeranotation to your configuration for enable grpc server - Customize configuration - application.yml/application.property. Example:
grpc:
enabled: true
servers:
-
address: 127.0.0.1
port: 6565
-
address: 127.0.0.1
port: 0Use port: 0 for auto assign random port
or
grpc.enabled: true
grpc.servers[0].address=127.0.0.1
grpc.servers[0].port=6565
grpc.servers[0].address=127.0.0.1
grpc.servers[0].port=0 - port 6565
- host/ip localhost/127.0.0.1
If you want to run on random port (grpc.servers[0].port=0), you will need inject resulted port.
Use @GRPCLocalPort please for solve this
@GRPCLocalPort
int port| name | version |
|---|---|
| io.grpc:grpc-stub | 1.7.0 |
| io.grpc:grpc-protobuf | 1.7.0 |
| io.grpc:grpc-netty | 1.7.0 |
| com.google.protobufprotoc | 3.2.0 |
| Spring Boot | 1.5.8.RELEASE |