You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documentation uses incorrect annotation in the code example #2352
Sometimes, you may want to write a custom handler for a specific resource. To take advantage of Spring Data REST’s settings, message converters, exception handling, and more, use the @RepositoryRestController annotation instead of a standard Spring MVC @Controller or @RestController. Controllers annotated with @RepositoryRestController are served from the API base path defined in RepositoryRestConfiguration.setBasePath, which is used by all other RESTful endpoints (for example, /api). The following example shows how to use the @RepositoryRestController annotation:
However in the code block after this text @BasePathAwareController annotation is used:
@BasePathAwareController
class ScannerController {
private final ScannerRepository repository;
ScannerController(ScannerRepository repository) {
repository = repository;
}
@GetMapping(path = "/scanners/search/producers")
ResponseEntity<?> getProducers() {
List<String> producers = repository.listProducers();
//
// do some intermediate processing, logging, etc. with the producers
//
CollectionModel<String> resources = CollectionModel.of(producers);
resources.add(linkTo(methodOn(ScannerController.class).getProducers()).withSelfRel());
// add other links as needed
return ResponseEntity.ok(resources);
}
}
Activity
oTAETAEo commentedon Jan 9, 2026
Hi @odrotbohm,
I checked the current documentation at https://docs.spring.io/spring-data/rest/reference/customizing/overriding-sdr-response-handlers.html and the code example now correctly uses
@RepositoryRestControllerinstead of@BasePathAwareController.It appears this issue has been resolved. Could this issue be closed?