I am trying to integrate Resteasy and Spring; I have followed both the docs for Resteasy and this post: Inject Spring beans into RestEasy . I have it working using @Autowire or other Spring annotations on the rest class, but I would like to do this keeping my rest classes free from spring (or DI) dependencies. I also would like to configure spring only through java configuration. In spring configuration I added this:
<context:component-scan base-package="package.where.spring.configuration.beans.are , package.where.rest.classes.are">
<context:include-filter type="annotation" expression="javax.ws.rs.Path"/>
</context:component-scan>
and of course I have in web.xml, so that spring config is picked up by SpringContextLoaderListener:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/spring-config.xml</param-value>
</context-param>
Removing the @Autowire annotations, if I also remove the first package (where I configured the injections through Spring java config) no injection takes place and the fields remain null; if I remove the second package the urls for the rest classes are not recognized by resteasy.
I would like to configure the injections just in Spring configuration, is there a way to have resteasy recognize the paths from spring beans which are configured externally?
EDIT: I noticed that what I am trying to do works with @Provider annotated classes, given that you configure Spring correctly:
<context:component-scan base-package="my.package1 , my.package2">
<context:include-filter type="annotation" expression="javax.ws.rs.ext.Provider"/>
</context:component-scan>
But the mistery is deeper than I first thought... I am more confident that I am on the right track and just missed a step!