是否可以使用相同的地址配置多个端点或使用一个具有多个bean的端点?
<jaxrs:server id="ServiceAImpl" address="/test">
<jaxrs:serviceBeans>
<ref bean="serviceABean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean ="jsonProvider" />
</jaxrs:providers>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
<entry key="json" value="application/json" />
</jaxrs:extensionMappings>
<jaxrs:features>
<cxf:logging/>
</jaxrs:features>
</jaxrs:server>
<jaxrs:server id="serviceBImpl" address="/test">
<jaxrs:serviceBeans>
<ref bean="serviceBBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean ="jsonProvider" />
</jaxrs:providers>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
<entry key="json" value="application/json" />
</jaxrs:extensionMappings>
<jaxrs:features>
<cxf:logging/>
</jaxrs:features>
</jaxrs:server>
要么配置如上,要么我只使用一个端点,但有两个bean。这个解决方案的问题是我无法访问第一个bean中的web服务。
<jaxrs:server id="serviceImpl" address="/test">
<jaxrs:serviceBeans>
<ref bean="serviceABean"/>
<ref bean="serviceBBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean ="jsonProvider" />
</jaxrs:providers>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
<entry key="json" value="application/json" />
</jaxrs:extensionMappings>
<jaxrs:features>
<cxf:logging/>
</jaxrs:features>
</jaxrs:server>
哪种使用方法正确?
答案 0 :(得分:0)
您可以同等地使用
<jaxrs:server id="ServiceAImpl" address="/test/a">
<jaxrs:server id="ServiceBImpl" address="/test/b">
<jaxrs:server id="serviceImpl" address="/test">
<jaxrs:serviceBeans>
<ref bean="serviceABean"/> <!-- /test/a service -->
<ref bean="serviceBBean"/> <!-- /test/b service -->
但不允许
<jaxrs:server id="ServiceAImpl" address="/test">
<jaxrs:server id="ServiceBImpl" address="/test">