I have a library that contains the DTO and service interface.
@RequestMappping("/api/foo")
public interface FooApi {
@GetMapping("/{id}")
Foo getFooById(@pathVariable long id);
}
The server implements that interface:
@RestController
public FooController implements FooApi {
Foo getFooById(long id) {
return fooService.getById(id);
}
}
And I have clients that also implement that interface:
@Component
public FooClient implements FooApi {
Foo getFooById(long id) {
return restTemplate.getObject(baseUrl + "/api/foo/{id}", ...);
}
}
(in the future the client implementation will get derived from the annotations at runtime: clientFactory.createInstance(FooApi.class)
)
Is there a way to tell Spring to not treat the FooClient
as a Controller, because I didn't annotate it as such?
(Without removing the @RequestMapping
s from the FooApi
interface entirely?)
I'm using Spring-Boot 2.7.