Java / Micronaut Interview questions
What is the difference between @Client and @Controller in Micronaut?
| @Controller | @Client |
| Defines endpoints your application exposes to callers. | Defines endpoints your application calls on another service. |
| Implemented as a concrete class with method bodies. | Declared as an interface; Micronaut generates the implementation. |
| Registered as routes in the embedded HTTP server. | Used as an injectable bean to make outbound HTTP calls. |
Both share the same HTTP annotations, such as @Get, @Post, and @PathVariable, which is intentional: it means the same mental model of routes, verbs, and bindings applies whether you're describing what your service serves or what it consumes, just pointed in opposite directions.
More Related questions...