springboot2.0.4整合cxf的问题

最近开发springboot整合cxf,以及springboot升级发现了很多烦人的问题,在此记录一下:

刚开始用的springboot版本是1.5.12,后来升级为springboot 2.0.4.

配置cxf如下:

@Configuration
public class WebServiceConfig {
    @Bean
    public ServletRegistrationBean dispatcherServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
    }
    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }


    @Bean
    public UMIServiceSoap uMIServiceSoap() {
        return new UMIServiceSoapImpl();
    }
    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), uMIServiceSoap());
        endpoint.publish("/XXService");
        return endpoint;
    }


}

然后启动项目报错:

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.
    - Bean method 'dispatcherServletRegistration' 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.

        网上查了半天,一无所获,不断尝试不同的springboot版本,最终发现2.0.3没有问题,2.0.4之后的版本都有这个问题。

把版本调成2.0.3后,发现新的问题。就是配置了

后,webservice访问没有问题,但是controller都访问不到,经网上查找可通过在application.properties或者application.yml配置

cxf.path=/webservice

解决问题,这样就不用在代码中配置dispatcherServlet()。

这样的话是不是springboot版本的问题就解决了呢?

进过测试springboot2.0.4版本启动、webservice访问、controller访问都没有问题了。

解决controller和webservice访问的问题是看了下面的博客,在此谢谢大牛:

spring boot 集成cxf时Controller映射报错的坑

 

 

 

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值