尝试使用 Tomcat 7 Maven 插件和 CXF 2.7.8 部署 JAX-WS 端点。作为一个偏好问题,我不想为 Spring 或 CXF 进行任何 XML 配置。我看到一些博客、文章、帖子使用cxf-servlet.xml
和 CXFServlet,但没有一个完全使用 Java 配置。查看 CXFServlet 源代码,它会cxf-servlet.xml
在 servlet 上下文中的 key 下查找 或任何内容'config-location'
。我尝试以编程方式注册端点而不是 in cxf-servlet.xml
,但它不起作用;访问服务时收到 404。有任何想法吗?
@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;
}
}