5

Given the following working repository in our application:

public interface PersonRepository extends PagingAndSortingRepository<Person, Integer> { } 

The Repository is exposed via spring-data-rest with URI "/api/persons" and works as expected.

We now want to override the post-method of the repository in a method of a RestController:

@RestController @RequestMapping("/persons") public class PersonController { @RequestMapping(value = "/**", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> savePerson(@RequestBody Person person) { //do something fancy return "it works"; } 

If we post data to "/api/persons" the method of the PersonController is called but none of the methods of the PersonRepository (e.g. GET) can be accessed via rest. We constantly get an 405 error and the following exception:

org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported 

After some playing around we found out that everything works as expected (methods of repository and controller can be called) if we change the value-property of the @RequestMapping annotation from

value="/**" 

to

value="/save" 

After reading this question and the linked documenation it should also work if the value-property is "/**"

1 Answer 1

2

Finally, after upgrading to new versions of spring/spring-data/spring-data-rest everything works as expected.

Sign up to request clarification or add additional context in comments.

1 Comment

it still doesn't work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.