Skip to content

Commit 17aaf87

Browse files
feat: add new module[spring-boot-grpc]
1 parent fae8c51 commit 17aaf87

File tree

9 files changed

+62
-52
lines changed

9 files changed

+62
-52
lines changed

build.gradle

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ allprojects {
3636
set("springBootVersion", "2.7.4")
3737
set("springCloudVersion", "Hoxton.SR10")
3838
set("springCloudAlibabaVersion", "2.2.6.RELEASE")
39-
set("grpcVersion", "1.39.0")
40-
set("protocVersion", "3.17.2")
39+
4140
}
4241

4342

@@ -47,15 +46,6 @@ allprojects {
4746
// mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
4847
// mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:${springCloudAlibabaVersion}"
4948
}
50-
dependencies {
51-
// grpc
52-
dependency "io.grpc:grpc-protobuf:${grpcVersion}"
53-
dependency "io.grpc:grpc-stub:${grpcVersion}"
54-
dependency "io.grpc:grpc-netty-shaded:${grpcVersion}"
55-
dependency "io.grpc:grpc-core:${grpcVersion}" // spring 依赖管理中定义了,需要重新声明
56-
dependency "io.grpc:grpc-api:${grpcVersion}" // spring 依赖管理中定义了,需要重新声明
57-
58-
}
5949
}
6050

6151
dependencies {

experimental-code/build.gradle

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,11 @@
1-
plugins {
2-
id "com.google.protobuf" version "0.8.16"
3-
id "org.springframework.boot"
1+
dependencyManagement {
2+
imports {
3+
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
4+
}
45
}
56

6-
7-
8-
97
dependencies {
10-
// grpc
11-
implementation "io.grpc:grpc-protobuf"
12-
implementation "io.grpc:grpc-stub"
13-
runtimeOnly "io.grpc:grpc-netty-shaded"
14-
15-
api("org.springframework.boot:spring-boot-starter-web")
16-
implementation "com.squareup.okhttp3:okhttp"
17-
implementation "com.github.ben-manes.caffeine:caffeine"
18-
19-
api("org.springframework.boot:spring-boot-starter-actuator")
20-
}
8+
api("com.google.protobuf:protobuf-java:3.11.0")
219

22-
23-
protobuf {
24-
protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
25-
plugins {
26-
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
27-
}
28-
generateProtoTasks {
29-
all()*.plugins { grpc {} }
30-
}
31-
}
32-
33-
// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
34-
sourceSets {
35-
main {
36-
java {
37-
srcDirs "build/generated/source/proto/main/grpc"
38-
srcDirs "build/generated/source/proto/main/java"
39-
}
40-
}
10+
testImplementation("org.springframework.boot:spring-boot-starter-test")
4111
}

settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ include "spring-boot-pulsar"
5151

5252
include "spring-boot-methodHandler"
5353

54+
include "spring-boot-grpc"
55+
5456
// spring boot examples
5557
include "spring-boot-examples:spring-boot-redis"
56-
include "spring-boot-examples:spring-boot-pulsar"
5758
include "spring-boot-examples:spring-boot-webmvc"
5859
include "spring-boot-examples:spring-boot-dubbo3:spring-boot-dubbo3-consumer"
5960
include "spring-boot-examples:spring-boot-dubbo3:spring-boot-dubbo3-provider"

spring-boot-examples/spring-boot-dubbo3/spring-boot-dubbo3-consumer/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ plugins {
33
}
44

55
ext {
6-
DUBBO_VERSION = "3.0.5"
6+
set("DUBBO_VERSION", "3.0.5")
7+
set("protocVersion", "3.17.2")
78
}
89

910
protobuf {

spring-boot-examples/spring-boot-dubbo3/spring-boot-dubbo3-provider/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ plugins {
33
}
44

55
ext {
6-
DUBBO_VERSION = "3.0.5"
6+
set("DUBBO_VERSION", "3.0.5")
7+
set("protocVersion", "3.17.2")
78
}
89

910
protobuf {

spring-boot-grpc/build.gradle

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
plugins {
2+
id "com.google.protobuf" version "0.8.16"
3+
}
4+
5+
ext {
6+
set("grpcVersion", "1.39.0")
7+
set("protocVersion", "3.17.2")
8+
}
9+
10+
11+
dependencyManagement {
12+
imports {
13+
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
14+
}
15+
}
16+
17+
dependencies {
18+
// grpc
19+
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
20+
implementation "io.grpc:grpc-stub:${grpcVersion}"
21+
runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"
22+
23+
api("org.springframework.boot:spring-boot-starter-web")
24+
25+
testImplementation("org.springframework.boot:spring-boot-starter-test")
26+
}
27+
28+
29+
protobuf {
30+
protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
31+
plugins {
32+
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
33+
}
34+
generateProtoTasks {
35+
all()*.plugins { grpc {} }
36+
}
37+
}
38+
39+
// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
40+
sourceSets {
41+
main {
42+
java {
43+
srcDirs "src/main/proto"
44+
srcDirs "build/generated/source/proto/main/grpc"
45+
srcDirs "build/generated/source/proto/main/java"
46+
}
47+
}
48+
}

experimental-code/src/main/java/com/ooooo/grpc/GrpcClient.java renamed to spring-boot-grpc/src/main/java/com/ooooo/grpc/GrpcClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import com.ooooo.grpc.helloworld.HelloRequest;
66
import io.grpc.ManagedChannel;
77
import io.grpc.ManagedChannelBuilder;
8-
import lombok.SneakyThrows;
9-
108
import java.util.concurrent.TimeUnit;
9+
import lombok.SneakyThrows;
1110

1211
/**
1312
* @author ooooo

0 commit comments

Comments
 (0)