Setting Up a gRPC Server in Spring Boot
Fast recall
Quick revision
Core answer
**gRPC**-spring-boot-starter dependency (by LogNet or net.devh), place your .proto files under src/main/proto, configure the plugin to generate Java stubs, annotate your service implementation with @GrpcService, and configure the port in application.yml. Spring Boot auto-configures the gRPC server lifecycle, interceptor wiring, and health checks.Evaluates practical experience integrating gRPC into the Spring Boot ecosystem.
Interviewers want to see you know the full setup — dependencies, code generation, annotation, and configuration — not just the theory.
Interviewers want to see you know the full setup — dependencies, code generation, annotation, and configuration — not just the theory.
Interview-ready guide
Interview answer
Setting up a gRPC server in Spring Boot with grpc-spring-boot-starter is clean once you understand the dual-server model. Your application runs two servers simultaneously, and both need to be configured correctly.
The basic setup:
- Add
net.devh:grpc-spring-boot-starterdependency, setgrpc.server.portinapplication.yml— typically 9090 — and annotate your service implementation with@GrpcService - The starter handles Netty server startup, service registration, and lifecycle management alongside the Spring context; your service class is a regular Spring bean with full support for constructor injection,
@Transactional, and configuration properties - On the client side,
@GrpcClientinjects a managed stub with a logical service name configured in YAML — addresses can switch fromstatic://for dev todns://for production service discovery without recompiling
The dual-server model — the critical detail:
- Your application runs HTTP on port 8080 and gRPC on port 9090; that means two health checks, potentially two TLS certificate sets for mTLS, and two port entries in your Kubernetes Service definition
- A common deployment mistake: the K8s manifest exposes only port 8080, so gRPC is unreachable in the cluster with no obvious error — the service starts fine but all gRPC clients get connection refused
Test configuration:
- Always set
grpc.server.port: 0in test properties to use a random port; parallel test suites binding the same port is a frequent CI failure source that's hard to debug
I recommend verifying both ports appear in your Kubernetes Service manifest before the first cluster deployment — and confirming the starter version matches your Spring Boot major version, since Boot 2.x and 3.x have different APIs that cause NoSuchMethodError on startup if mismatched.
Setting Up a gRPC Server in Spring Boot
Direct Answer
Add the **gRPC**-spring-boot-starter dependency (by LogNet or net.devh), place your .proto files under src/main/proto, configure the plugin to generate Java stubs, annotate your service implementation with @GrpcService, and configure the port in application.yml. Spring Boot auto-configures the gRPC server lifecycle, interceptor wiring, and health checks.
Common Mistakes & Pitfalls
Interviewers want to see you know the full setup — dependencies, code generation, annotation, and configuration — not just the theory.
Check your understanding
Answer these without looking back at the article.
- How do you enable TLS for the gRPC server in Spring Boot?
- How does grpc-spring-boot-starter integrate with Spring Security?
- What is the difference between blocking stubs, async stubs, and future stubs?
Related interview prep categories
1Want a guided curriculum order?
These modules are also sequenced in our flagship backend interview track — open it when you prefer an ordered path instead of browsing by topic.