Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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>

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
215 views
Welcome To Ask or Share your Answers For Others

1 Answer

Tested and working in cxf 3.0.4.

<jaxrs:server address="/" basePackages="a.b.c"/>

Dont forget to mention the cxf-servlet in web.xml


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...