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

    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

              • Assignee:
                olivergierke Oliver Drotbohm
                Reporter:
                felixhuch Felix Huch
                Last updater:
                Robert Rackl
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: