Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Documentation uses incorrect annotation in the code example

Aperta
#2,352 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@odrotbohm ci sta già lavorando.

Dal 22/1/2024.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

status: waiting-for-triage

Hi

Current documentation section that describes overriding default response handlers (https://docs.spring.io/spring-data/rest/reference/customizing/overriding-sdr-response-handlers.html) states multiple times that @RepositoryRestController annotation should be used:

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); 
  }
}

Spring Data REST: 4.2.1

Lingua principale
Java
Stelle
957
Fork
570
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di spring-projects/spring-data-rest

Tutte le issue di spring-projects/spring-data-rest

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.