...
Code Block | ||||
---|---|---|---|---|
| ||||
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<!--
Discover all root resources and providers in packages starting from "a.b.c"
-->
<jaxrs:server address="/customers" basePackages="a.b.c"/>
<!--
Discover a root resource and providers in packages starting from "a.b.c" and "d.e.f",
Note that in case of jaxrs:client, having multiple discoverable root resources can lead to
unexpected results, as only the single root can be recognized
-->
<jaxrs:client address="http://customers" basePackages="a.b.c,d.e.f"/>
</beans>
|
Note the above does not require Spring annotations such as @Component added to JAX-RS provider or resources.
If you prefer doing a pure Spring-based auto-discovery you can have @Component added to JAX-RS application classes and do
Code Block | ||||
---|---|---|---|---|
| ||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml" /> <!-- Discover all root resources and providers in packages starting from "a.b.c" --> <jaxrs:server address="/customers"/> <context:component-scan <base-package="a.b.c"/> </beans> |
Servlet and Application Container Configuration
Please see this page for more information.
Starting from CXF 3.1.0: JaxrsServletContextInitializer will be chiiped in a cxf-rt-rs-http-sc module. This will support no-web.xml and other JAX-RS deployments depending on the container auto-discovery mechanism as described in a 2.3.2 section of JSR-339 (JAX-RS 2.0).