Inject Spring beans into RestEasy Inject Spring beans into RestEasy spring spring

Inject Spring beans into RestEasy


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.


There is a working example that integrates RestEasy with Spring just try spring-resteasy.


You could use the @Configurable annotation to make a normal class (created by new) a spring Bean.Then you can use the normal Spring annotation to inject everything in that class/instance like in a "normal" Spring Bean.

But that requires AspectJ!

@See Spring Reference Chapter 7.8.1 Using AspectJ to dependency inject domain objects with Spring