使用 Spring Boot 暴露 WebService 接口.
gav |
---|
org.springframework.boot:spring-boot-starter-web-services:2.1.13.RELEASE |
org.apache.cxf:cxf-spring-boot-starter-jaxws:3.3.6 |
org.apache.cxf:cxf-rt-transports-http:3.3.6 |
2021-05-17 10:46:56.613 ERROR 195180 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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.
@Configuration
public class CXFConfig {
@Bean
public ServletRegistrationBean dispatcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/webservices/*");
}
}
CXFConfig
配置类里注册 Servlet 的 Bean 的 name 是dispatcherServlet
,造成错误的。
因此需要调整注册的 Servlet 的 Bean 的名称。
调整注册的 Servlet 的 Bean 的名称,避免Bean(name = "dispatcherServlet")
@Configuration
public class CXFConfig {
@Bean
public ServletRegistrationBean cxfServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/webservices/*");
}
}
springboot整合cxf启动报错,原因是版本问题 - https://princeyao.blog.csdn.net/article/details/113177336