Skip to content

Commit 78796f7

Browse files
authored
Use Spring gRPC from Spring Boot
- Removed redundant dependencies - Removed unused properties * Remove unused version from build.gradle - localized the server port `@value` * Merge grpServerAddress param def into single line
1 parent 0bf330d commit 78796f7

File tree

4 files changed

+62
-83
lines changed

4 files changed

+62
-83
lines changed

basic/grpc-client/pom.xml

Lines changed: 54 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,62 @@
6060
<system>GitHub</system>
6161
<url>https://github.com/spring-projects/spring-integration-samples/issues</url>
6262
</issueManagement>
63+
<dependencies>
64+
<dependency>
65+
<groupId>org.springframework.boot</groupId>
66+
<artifactId>spring-boot-starter-integration</artifactId>
67+
<scope>runtime</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.springframework.boot</groupId>
71+
<artifactId>spring-boot-starter-grpc-client</artifactId>
72+
<scope>runtime</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.springframework.integration</groupId>
76+
<artifactId>spring-integration-grpc</artifactId>
77+
<scope>runtime</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.hamcrest</groupId>
81+
<artifactId>hamcrest-library</artifactId>
82+
<version>2.2</version>
83+
<scope>test</scope>
84+
</dependency>
85+
<dependency>
86+
<groupId>org.mockito</groupId>
87+
<artifactId>mockito-core</artifactId>
88+
<version>5.21.0</version>
89+
<scope>test</scope>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.junit.jupiter</groupId>
93+
<artifactId>junit-jupiter-api</artifactId>
94+
<scope>test</scope>
95+
</dependency>
96+
<dependency>
97+
<groupId>org.springframework.integration</groupId>
98+
<artifactId>spring-integration-test</artifactId>
99+
<scope>test</scope>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.springframework.boot</groupId>
103+
<artifactId>spring-boot-starter-grpc-test</artifactId>
104+
<scope>test</scope>
105+
</dependency>
106+
<dependency>
107+
<groupId>org.junit.jupiter</groupId>
108+
<artifactId>junit-jupiter-engine</artifactId>
109+
<scope>runtime</scope>
110+
</dependency>
111+
<dependency>
112+
<groupId>org.junit.platform</groupId>
113+
<artifactId>junit-platform-launcher</artifactId>
114+
<scope>runtime</scope>
115+
</dependency>
116+
</dependencies>
63117
<dependencyManagement>
64118
<dependencies>
65-
<dependency>
66-
<groupId>org.springframework.grpc</groupId>
67-
<artifactId>spring-grpc-dependencies</artifactId>
68-
<version>1.0.2</version>
69-
<type>pom</type>
70-
<scope>import</scope>
71-
</dependency>
72119
<dependency>
73120
<groupId>org.springframework.integration</groupId>
74121
<artifactId>spring-integration-jdbc</artifactId>
@@ -328,71 +375,6 @@
328375
</dependency>
329376
</dependencies>
330377
</dependencyManagement>
331-
<dependencies>
332-
<dependency>
333-
<groupId>org.springframework.boot</groupId>
334-
<artifactId>spring-boot-starter-integration</artifactId>
335-
<scope>runtime</scope>
336-
</dependency>
337-
<dependency>
338-
<groupId>org.springframework.grpc</groupId>
339-
<artifactId>spring-grpc-client-spring-boot-starter</artifactId>
340-
<scope>runtime</scope>
341-
</dependency>
342-
<dependency>
343-
<groupId>org.springframework.integration</groupId>
344-
<artifactId>spring-integration-grpc</artifactId>
345-
<scope>runtime</scope>
346-
</dependency>
347-
<dependency>
348-
<groupId>com.google.protobuf</groupId>
349-
<artifactId>protobuf-java</artifactId>
350-
<version>4.29.4</version>
351-
<scope>runtime</scope>
352-
</dependency>
353-
<dependency>
354-
<groupId>org.hamcrest</groupId>
355-
<artifactId>hamcrest-library</artifactId>
356-
<version>2.2</version>
357-
<scope>test</scope>
358-
</dependency>
359-
<dependency>
360-
<groupId>org.mockito</groupId>
361-
<artifactId>mockito-core</artifactId>
362-
<version>5.21.0</version>
363-
<scope>test</scope>
364-
</dependency>
365-
<dependency>
366-
<groupId>org.junit.jupiter</groupId>
367-
<artifactId>junit-jupiter-api</artifactId>
368-
<scope>test</scope>
369-
</dependency>
370-
<dependency>
371-
<groupId>org.springframework.integration</groupId>
372-
<artifactId>spring-integration-test</artifactId>
373-
<scope>test</scope>
374-
</dependency>
375-
<dependency>
376-
<groupId>org.springframework.boot</groupId>
377-
<artifactId>spring-boot-starter-test</artifactId>
378-
<scope>test</scope>
379-
</dependency>
380-
<dependency>
381-
<groupId>org.springframework.grpc</groupId>
382-
<artifactId>spring-grpc-test</artifactId>
383-
<scope>test</scope>
384-
</dependency>
385-
<dependency>
386-
<groupId>org.junit.jupiter</groupId>
387-
<artifactId>junit-jupiter-engine</artifactId>
388-
<scope>runtime</scope>
389-
</dependency>
390-
<dependency>
391-
<groupId>org.junit.platform</groupId>
392-
<artifactId>junit-platform-launcher</artifactId>
393-
<scope>runtime</scope>
394-
</dependency>
395-
</dependencies>
396378
<properties>
397379
<java.version>17</java.version>
398380
</properties>

basic/grpc-client/src/main/java/org/springframework/integration/samples/grpc/client/GrpcClientConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.beans.factory.annotation.Qualifier;
26+
import org.springframework.beans.factory.annotation.Value;
2627
import org.springframework.boot.ApplicationRunner;
2728
import org.springframework.context.annotation.Bean;
2829
import org.springframework.context.annotation.Configuration;
@@ -47,8 +48,9 @@ public class GrpcClientConfiguration {
4748
private static final Log LOGGER = LogFactory.getLog(GrpcClientConfiguration.class);
4849

4950
@Bean
50-
ManagedChannel managedChannel(GrpcChannelFactory factory) {
51-
return factory.createChannel("spring-integration");
51+
ManagedChannel managedChannel(GrpcChannelFactory factory,
52+
@Value("${spring.grpc.client.channels.spring-integration.address}") String grpcServerAddress) {
53+
return factory.createChannel(grpcServerAddress);
5254
}
5355

5456
/**

basic/grpc-client/src/test/java/org/springframework/integration/samples/grpc/client/GrpcClientTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
* @author Glenn Renfro
3838
*/
3939
@SpringBootTest(properties = {
40-
"spring.grpc.test.inprocess.enabled=true",
41-
"spring.grpc.test.inprocess.exclusive=true"
40+
"spring.grpc.server.inprocess.name=test",
41+
"spring.grpc.client.channels.spring-integration.address=in-process:test"
4242
})
4343
@DirtiesContext
4444
@ExtendWith(OutputCaptureExtension.class)

build.gradle

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ subprojects { subproject ->
330330
protobufVersion = '4.29.4'
331331
slf4jVersion = '2.0.17'
332332
springCloudVersion = '2025.1.0'
333-
springGrpc = '1.0.2'
334333
springIntegrationVersion = '7.1.0-SNAPSHOT'
335334
set('spring-integration.version', "$springIntegrationVersion")
336335
springIntegrationSocialTwiterVersion = '1.0.1.BUILD-SNAPSHOT'
@@ -887,16 +886,12 @@ project('grpc-client') {
887886
apply plugin: 'com.google.protobuf'
888887

889888
dependencies {
890-
implementation platform("org.springframework.grpc:spring-grpc-dependencies:$springGrpc")
891889
implementation 'org.springframework.boot:spring-boot-starter-integration'
892-
implementation "org.springframework.grpc:spring-grpc-client-spring-boot-starter"
890+
implementation "org.springframework.boot:spring-boot-starter-grpc-client"
893891
implementation 'org.springframework.integration:spring-integration-grpc'
894892

895-
implementation("com.google.protobuf:protobuf-java:$protobufVersion")
896-
897893
//Test
898-
testImplementation 'org.springframework.boot:spring-boot-starter-test'
899-
testImplementation "org.springframework.grpc:spring-grpc-test"
894+
testImplementation "org.springframework.boot:spring-boot-starter-grpc-test"
900895

901896
configurations {
902897
testRuntimeOnly.exclude group: 'io.grpc', module: 'grpc-netty'

0 commit comments

Comments
 (0)