在Spring应用程序中使用CXF自动发现JAX-RS资源 [英] Autodiscover JAX-RS resources with CXF in a Spring application

查看:225
本文介绍了在Spring应用程序中使用CXF自动发现JAX-RS资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache CXF(2.7.0)是否可以自动发现类路径中的JAX-RS资源?也就是说,用 @Path 注释的类。

Is it possible with Apache CXF (2.7.0) to automatically discover JAX-RS resources in the classpath? That is, classes annotated with @Path.

我在Spring应用程序中使用CXF而且我必须手动使用以下XML声明资源,即使Spring < context:component-scan ...> 成功发现了资源。

I am using CXF in a Spring application and I have to manually declare the resources with the following XML, even if the resources are successfully discovered by Spring <context:component-scan ...>.

<jaxrs:server id="myService" address="/myService">
    <jaxrs:serviceBeans>
        <ref bean="myResource1" />
        <ref bean="myResource2" />
        <ref bean="myResource3" />
    </jaxrs:serviceBeans>
</jaxrs:server>

我想避免它(因为我可以使用其他JAX-RS实现,例如resteasy)因为在我的情况下它很难维护,它迫使我在Spring XML配置文件中声明我的bean依赖项。

I would like to avoid it (as I can do with other JAX-RS implementations such as resteasy) because in my case it is harder to maintain, and it forces me to declare my bean dependencies in the Spring XML configuration file.

推荐答案

在CXF 2.7中,目前看起来没有办法在Spring配置中执行此操作。如果你看看resteasy,他们已经实现了一个查找@Path和@Provider的BeanFactoryPostProcessor SpringBeanProcessor.java。类似的东西可能在CXF中完成,但似乎还没有实现。看起来你并不是唯一感兴趣的人 CXF-3725

It doesn't look like there's a way to do this with Spring configuration at this time in CXF 2.7. If you look at resteasy they've implemented a BeanFactoryPostProcessor SpringBeanProcessor.java that looks for @Path and @Provider. Something similar could be probably be done in CXF but it doesn't appear to be implemented yet. Looks like you're not the only one interested CXF-3725

这篇关于在Spring应用程序中使用CXF自动发现JAX-RS资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆