Spring Data REST takes an opinionated approach to exposing Spring Data repositories via REST endpoints, covering the 80-90% use case with a minimum of code and fuss. But did you know that it provides a no-lifting-required mechanism for exposing query methods you define on those repositories as well?
Let’s say you create a method like this:
Referencing that bit of functionality directly is simple, just append /search/<methodName> to the collection endpoint:
For more information, click here to view the Spring Data REST docs. Keep coding/keep sharing!
P.S. – Find this useful? Click here to follow me on Twitter and be notified of future posts! And don’t forget to share this Quick Tip via the button(s) below. Thanks!
Tags: query method, quick tip, REST, Spring, Spring Data, Spring Data REST