Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.lavcraft:grpc-spring-boot-starter:0.8.1'
}
dependencies {
implementation("com.github.lavcraft:grpc-spring-boot-starter:0.8.1")
}
<dependency>
<groupId>com.github.lavcraft</groupId>
<artifactId>grpc-spring-boot-starter</artifactId>
<version>0.8.1</version>
</dependency>
libraryDependencies += "com.github.lavcraft" % "grpc-spring-boot-starter" % "0.8.1"
:dependencies [[com.github.lavcraft/grpc-spring-boot-starter "0.8.1"]]
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
@EnableGRpcServer
anotation to your configuration for enable grpc servergrpc:
enabled: true
servers:
-
address: 127.0.0.1
port: 6565
-
address: 127.0.0.1
port: 0
Use 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
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 |