[SpringBoot]微服务中的Springboot突然返回xml格式报文排查

问题背景

mate-starter-web集成全局异常拦截返回的是json报文,某天突然返回了xml报文,后期集成了sentinel。怀疑是其捣的鬼

问题排查

经排查发现,是jackson-dataformat-xml这个依赖导致的。可以通过如下分析查找依赖

[SpringBoot]微服务中的Springboot突然返回xml格式报文排查_第1张图片
原来是引用spring-cloud-starter-alibaba-sentinel这个依赖的时候,带上了这个

解决方案

        <dependency>
            <groupId>com.alibaba.cloudgroupId>
            <artifactId>spring-cloud-starter-alibaba-sentinelartifactId>
            <exclusions>
                <exclusion>
                    <artifactId>jackson-dataformat-xmlartifactId>
                    <groupId>com.fasterxml.jackson.dataformatgroupId>
                exclusion>
            exclusions>
        dependency>

引入依赖的时候,排除掉jackson-dataformat-xml即查

示例代码

https://github.com/matevip/matecloud

你可能感兴趣的:(微服务,spring,boot,json,xml,matecloud,spring)