idea中springboot2.7项目集成cxf webservice,在tomcat启动时提示:java.lang.ClassNotFoundException: org.apache.cxf.Bus
我的webservice配置类:
import org.apache.cxf.Bus;//我确认好几遍,网上全部说的是这个,难到就我一人错了吗? import org.apache.cxf.bus.spring.SpringBus; import org.apache.cxf.bus.spring.SpringBusFactory; import org.apache.cxf.jaxws.EndpointImpl; import org.apache.cxf.transport.servlet.CXFServlet; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.annotation.Resource; import javax.xml.ws.Endpoint; /** * webService的配置 */ @Configuration public class WebServiceConfig_test{ @Resource private WebServiceDemoService webServiceDemoService; /** * 注入servlet bean name不能dispatcherServlet 否则会覆盖dispatcherServlet * @return */ @Bean public ServletRegistrationBean cxfServlet() { return new ServletRegistrationBean(new CXFServlet(),"/service/*"); } @Bean(name = Bus.DEFAULT_BUS_ID) public SpringBus springBus(){ return new SpringBus(); } // @Autowired // private Bus bus; /** * 注册WebServiceDemoService接口到webservice服务 * @return */ @Bean(name = "WebServiceDemoEndpoint") public Endpoint sweptPayEndpoint() { // Bus bus = new SpringBusFactory().createBus(); //return Endpoint.publish("http://localhost:8080/webservice/",webServiceDemoService); EndpointImpl endpoint = new EndpointImpl(springBus(), webServiceDemoService);//就这里提示 //通过getInInterceptors方法,向WebService服务添加拦截器。 endpoint.getInInterceptors().add(new AuthInterceptor()); endpoint.publish("/webservice"); return endpoint; } }