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!
Cheers,
Mark
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!
Related Posts:
Tags: query method,
quick tip,
REST,
Spring,
Spring Data,
Spring Data REST
I’ve only been working with Pivotal Cloud Foundry since September 2015, but I’ve learned a great deal about it since then. I also realize there is much (much much) more to learn! The world doesn’t stand still, after all, and there are many stones I’ve yet to turn.
Sometimes I revisit something small-but-useful that I discovered long ago that I didn’t take the time to share at the time. I intend to be better about that, beginning now. If this is something you use frequently, please disregard; if there is something you use in lieu of this tip or any other, please share. 😉
Anyway, many times when deploying an application to Cloud Foundry, you will want to generate a unique URL to avoid “collisions”, i.e. attempting to reuse an in-use URL. In the past, you would insert a ${random-word} Expression Language, er, expression to do this, but at some point, the preferred approach changed. To accomplish this now, simply add random-route: true to your application’s manifest.yml file. It should look something like this:
This directs Cloud Foundry to generate a couple of words randomly and append them to your application name with hyphens, resulting in a URL that looks something like https://example-app-saprophagous-unkindliness.cfapps.io.
You can also use the command line option –random-route.
For more information, please refer to the Pivotal Cloud Foundry docs.
Hope this helps,
Mark
Related Posts:
Tags: Cloud,
Cloud Foundry,
manifest,
manifest.yml,
random,
random URL,
random-route,
URL