springboot整合webservice,启动错误处理

错误一、DispatcherServlet Registration found non dispatcher servlet dispatcherServlet

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
Disconnected from the target VM, address: '127.0.0.1:58994', transport: 'socket'
2020-04-08 18:37:24.046 ERROR 29272 --- [           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

出现原因及解决办法

代码中初始化bean时有重名的dispatcherServlet,例如:
在这里插入图片描述

错误二、The following method did not exist: org.apache.cxf.common.jaxb.JAXBUtils.createMininumEscapeHandler(Ljava/lang/Class;)Ljava/lang/Object;

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-04-08 18:44:16.562 ERROR 27504 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.apache.cxf.jaxb.JAXBDataBinding.setContext(JAXBDataBinding.java:257)

The following method did not exist:

    org.apache.cxf.common.jaxb.JAXBUtils.createMininumEscapeHandler(Ljava/lang/Class;)Ljava/lang/Object;

The method's class, org.apache.cxf.common.jaxb.JAXBUtils, is available from the following locations:

    jar:file:/D:/maven-repository/org/apache/cxf/cxf-core/3.1.15/cxf-core-3.1.15.jar!/org/apache/cxf/common/jaxb/JAXBUtils.class

It was loaded from the following location:

    file:/D:/maven-repository/org/apache/cxf/cxf-core/3.1.15/cxf-core-3.1.15.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.apache.cxf.common.jaxb.JAXBUtils

Disconnected from the target VM, address: '127.0.0.1:59435', transport: 'socket'

Process finished with exit code 1

出现原因及解决办法

maven中引入的cxf-spring-boot-starter-jaxws版本中的cxf-core版本为3.1.5过低所致。网上说可以通过修改cxf-spring-boot-starter-jaxws的版本解决,但是springboot2.1.9试了遍后发现仍然报一样的错误,于是索性直接exclude掉cxf-spring-boot-starter-jaxws里的cxf-core,重新引入新版。
果然解决,pom.xml大致如下。

<properties>
        <cxf-spring-boot-starter-jaxws.version>3.2.5</cxf-spring-boot-starter-jaxws.version>
        <cxf-spring-boot-starter-jaxrs.version>3.2.5</cxf-spring-boot-starter-jaxrs.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
            <version>${cxf-spring-boot-starter-jaxws.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>cxf-core</artifactId>
                    <groupId>org.apache.cxf</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-core</artifactId>
            <version>3.2.6</version>
        </dependency>
    </dependencies>
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值