springboot整合CXF时,启动报错

Spring boot版本:2.2.0.M4
CXF版本:3.3.3
报错内容:

***************************
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.

报错原因:Spring boot版本太高
报错的代码处:

@Bean
    public ServletRegistrationBean dispatcherServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/cxf/*");// 发布服务名称 localhost:8080/cxf
    }

修改方法:
方法一:降低Spring boot版本,至2.0以下
方法二:删除上面报错代码处,并在application.yml中添加如下配置:

cxf:
  path: /cxf  

访问路径:localhost:8080/cxf/hello?wsdl

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一、SpringBoot简介 1.1 原有Spring优缺点分析 1.1.1 Spring的优点分析 Sprin...
    SingleXu阅读 9,852评论 1 20
  • WebService介绍 首先我们来谈一下为什么需要学习webService这样的一个技术吧.... 问题一 如果...
    Java3y阅读 13,224评论 5 139
  • 继上篇文章:Spring-Boot入门之环境搭建。这次我们整合SpringBoot-Mybatis实现简单的CRU...
    TyCoding阅读 13,039评论 3 60
  • SpringBoot基础 学习目标: 能够理解Spring的优缺点 能够理解SpringBoot的特点 能够理解S...
    dwwl阅读 10,783评论 4 81
  • 今天雨后初晴,格外闷热。等一个人的心反而平静,是看淡了,还是极度兴奋过后的冷却?不晓得,那就看看书慢慢消磨时光。吇...
    翁铁牛阅读 1,652评论 0 1

友情链接更多精彩内容