1.报错信息
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.8.RELEASE)
......中间部分省略......
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 1 of constructor 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.
The following candidates were found but could not be injected:
- Bean method 'dispatcherServletRegistration' in 'DispatcherServletAutoConfiguration.DispatcherServletRegistrationConfiguration' not loaded because DispatcherServlet Registration found non dispatcher servlet dispatcherServlet
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath' in your configuration.
Process finished with exit code 1
2.pom.xml文件说明
org.springframework.boot spring-boot-dependencies 2.1.8.RELEASE pom import
org.springframework.boot spring-boot-starter-web-services org.apache.cxf cxf-spring-boot-starter-jaxws 3.3.3
3.解决方式
在整合CXF的webservice时需要编写一个配置类:
@Configuration public class CxfConfig { // @Bean // @SuppressWarnings("unchecked") // public ServletRegistrationBean dispatcherServlet() { // return new ServletRegistrationBean(new CXFServlet(),"/AFIS/*"); // } @Bean public ServletRegistrationBean disServlet(){ return new ServletRegistrationBean(new CXFServlet() , "/AFIS/*"); } @Bean(name = Bus.DEFAULT_BUS_ID) public SpringBus springBus() { return new SpringBus(); } @Bean public Afis demoService() { return new AfisImpl(); } @Bean public Endpoint endpoint() { EndpointImpl endpoint = new EndpointImpl(springBus(), demoService()); endpoint.publish("/SJZWZDSB.WSD"); return endpoint; } }
将dispatcherServlet()方法重新命名就可以解决上述的报错信息。