Damo
Damo

Reputation: 1709

Rest Client as a spring bean

I need to implement a rest client to invoke a (third party) rest service. This client will be called from the context of a batch job, and thus will be (re)used a number of times. Is there a (standard) way that I can springify this setup, such that the Rest client is managed as a spring bean. This would allow me inject the client into the batch service. The alternative being that the service instantiates / configures the Rest client. I can see plenty of examples of how spring and restful services can be used together, but not so much info about rest clients and spring, so would also even like to know if this is a valid / worthwhile project setup. Thanks, Damien

Upvotes: 0

Views: 1746

Answers (1)

Steve
Steve

Reputation: 9480

The usual way is using a Spring REST template. There's a blog about it on the spring.io site:

http://spring.io/blog/2009/03/27/rest-in-spring-3-resttemplate/

That provides a reasonable example of how to do it.

Upvotes: 2

Related Questions