我正在使用以下内容使用 spring + jetty + cxf 创建一个 web 服务:
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint id="helloWorld" implementor="com.test.EndpointImp" address="http://localhost:9002/test">
</jaxws:endpoint>
这一切都按预期工作并且非常好。现在我需要“服务”一些 servlet。无论如何我可以访问为此创建的 jetty 服务器实例,以便我可以添加 servlet 吗?我不想只为我需要使用的 servlet 在另一个端口上创建另一个 Jetty 实例。
如有任何信息,我们将不胜感激。
最佳答案
this article 中描述了您正在寻找的解决方案.关键点(我在 my post 中也提到过)是在 web.xml
中使用 org.apache.cxf.transport.servlet.CXFServlet
,不要忘记导入 META-INF/cxf/cxf-servlet.xml
(你这样做了)并且还使用了相关的 address="/myservice"
属性。在这种情况下,CXF 例程不会启动嵌入式 Jetty,而是使用此 servlet 来处理入站请求。
关于java - 从 Spring Web 服务获取 Jetty 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9280894/