Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inject Spring beans into RestEasy

Is it possible to inject Spring beans into an RestEasy @Path class? I managed to do it with Jersey, with @InjectParam annotation, but for some other reasons, I need to switch to RestEasy, and I can't seem to find a way to do it (tried good ol' javax.inject.Inject, but nothing).

EDIT

This solution works: http://www.mkyong.com/webservices/jax-rs/resteasy-spring-integration-example/

but it's not injection.. I'd still prefer something a little more elegant.

like image 407
Robert Kovačević Avatar asked Jan 25 '12 20:01

Robert Kovačević


1 Answers

Simply annotate your RestEasy class with Spring's @Component and then inject your beans using Spring's @Autowired. Don't forget to include the annotation-config and component-scan elements in your spring configuration.

like image 100
Peter Cetinski Avatar answered Sep 29 '22 21:09

Peter Cetinski