我想知道在CXF XML上下文文件中
例如,如果我有两个服务实现,针对用户和订单,它们可以从相对路径
我应该这样配置服务:
或者这样做:
jaxrs:server
配置的首选语义是什么。例如,如果我有两个服务实现,针对用户和订单,它们可以从相对路径
"/user"
和"/order"
访问。我应该这样配置服务:
<jaxrs:server id="userService" address="/user">
<jaxrs:serviceBeans>
<bean class="com.example.UserServiceImpl />
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" />
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="orderService" address="/order">
<jaxrs:serviceBeans>
<bean class="com.example.OrderServiceImpl />
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" />
</jaxrs:providers>
</jaxrs:server>
或者这样做:
<jaxrs:server id="appService" address="/">
<jaxrs:serviceBeans>
<!--
Path configured using @Path annotations on the class definition:
@Path(value="/user")
public class UserServiceImpl {...}
-->
<bean class="com.example.UserServiceImpl />
<bean class="com.example.OrderServiceImpl />
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" />
</jaxrs:providers>
</jaxrs:server>
看起来这只是一个语义上的区别。第二种方式允许我们不重复提供者。但我想知道在执行此配置时应考虑哪些因素?
谢谢!