Apache CXF + Spring Java配置(无XML) [英] Apache CXF + Spring Java config (no XML)
问题描述
尝试使用Tomcat 7 Maven插件和CXF部署JAX-WS端点
2.7.8.作为首选,我不想为任何XML配置
Spring或CXF.我看到一些使用cxf-servlet.xml
的博客,文章和帖子
和CXFServlet,但完全不使用Java配置.查看CXFServlet源代码,它将在cxf-servlet.xml
或键'config-location'
下的servlet上下文中查找任何内容.我尝试以编程方式注册终结点,而不是在cxf-servlet.xml
中注册,但是它不起作用.访问该服务时,我收到404.有什么想法吗?
Trying to deploy a JAX-WS endpoint using Tomcat 7 Maven plugin and CXF
2.7.8. As a matter of preference, I don't want to have any XML config for
Spring or CXF. I see several blogs, articles, posts using cxf-servlet.xml
and CXFServlet but none whatsoever completely using Java config. Looking into the CXFServlet source code, it looks for the cxf-servlet.xml
or anything in the servlet context under the key 'config-location'
. I tried programmatically registering the endpoint instead of in cxf-servlet.xml
, but it doesn't work; I get a 404 when accessing the service. Any ideas?
@Configuration
@ImportResource({ "classpath:META-INF/cxf/cxf.xml" })
public class CXFConfig {
@Autowired
Bus cxfBus;
// More code
@Bean
public Endpoint calculator() {
EndpointImpl endpoint = new EndpointImpl(cxfBus, new Calculator());
endpoint.setAddress("/CalculatorService");
return endpoint;
}
}
推荐答案
所需的只是上面的endpoint.publish()
调用.
All that's needed is a endpoint.publish()
call above.
这篇关于Apache CXF + Spring Java配置(无XML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!