完整错误为
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-07-11 15:37:56.786 ERROR 3176 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method errorPageCustomizer in org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration required a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' in your configuration.
进程已结束,退出代码为 0
从org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' that could not be found.中可以看出找不到这个方法
代码为:
package com.rc.demo.config;// ~ File Information import com.rc.demo.webservice.HelloWordImpl; import org.apache.cxf.Bus; import org.apache.cxf.bus.spring.SpringBus; 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.xml.ws.Endpoint; /** * 类说明:webservice发布,默认访问地址为:localhost:8080/services/helloWord?wsdl */ @Configuration public class WebServiceConfig { // ~ Fields @Autowired private HelloWordImpl helloWord;//接口实现类 // ~ Methods /** * 此方法作用是改变项目中服务名的前缀名,此处127.0.0.1或者localhost不能访问时,请使用ipconfig查看本机ip来访问 * 此方法被注释后:wsdl访问地址为http://127.0.0.1:8080/services/user?wsdl * 去掉注释后:wsdl访问地址为:http://127.0.0.1:8080/soap/user?wsdl * @return */ @SuppressWarnings("all") @Bean public ServletRegistrationBean dispatcherServlet() { return new ServletRegistrationBean(new CXFServlet(), "/soap/*"); } @Bean(name = Bus.DEFAULT_BUS_ID) public SpringBus springBus() { return new SpringBus(); } @Bean public Endpoint endpoint() { EndpointImpl endpoint=new EndpointImpl(springBus(), helloWord); endpoint.publish("/helloWord");//访问地址 System.out.println("----------------helloWorlWebservice接口启动成功"); return endpoint; } }
我们给
public ServletRegistrationBean dispatcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/soap/*");
}
方法名dispathcerServlet改成其他名字就好比如说
public ServletRegistrationBean dispatcherServlet1() {
return new ServletRegistrationBean(new CXFServlet(), "/soap/*");
}
就可以了