Uploaded image for project: 'Spring Data REST'
  1. Spring Data REST
  2. DATAREST-522

GET on RestRepository not possible, if a RestController for the same path is available

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    Description

      We have a Spring Data REST project, with several @RepositoryRestResource annotated Spring Data Repositories.

      Example:

      PersonRepository.java
      @RepositoryRestResource(path = "person")
      public interface PersonRepository extends PagingAndSortingRepository<Person, Integer> {}
      

      We want to override the POST/PATCH method of one of these repositories. So we annotate a RestController with @RestController and the annotation @RequestMapping has the same path as the repository.

      Example:

      PersonController.java
      @RestController
      @RequestMapping("person")
      public class PersonController{
      
      	@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
      	public ResponseEntity<Boolean> savePerson(@RequestBody Person person) {
      ...
      }
      

      The POST/PATCH works fine. But now a GET to /person (to receive all Persons) throws an HttpRequestMethodNotSupportedException and says: Request method 'GET' not supported.

      A GET to /person/1 instead is working just fine.

      We had a look at https://jira.spring.io/browse/DATAREST-490 and the @BasePathAwareController, but this doesnt seem to change anything.

      Attachments

        Issue Links

          Activity

            People

              olivergierke Oliver Drotbohm
              felixhuch Felix Huch
              Archiver:
              tmarshall Trevor Marshall
              Spring Issues Spring Issues

              Dates

                Created:
                Updated:
                Resolved:
                Archived: