springboot2 集成 swagger3.0 使用了拦截器 出现报错 end of the stream or a document separator is expected

swagger版本:3.0.0

依赖:

<dependency>
	<groupId>io.springfox</groupId>
    <artifactId>springfox-boot-starter</artifactId>
    <version>3.0.0</version>
</dependency>

报错界面:
在这里插入图片描述
我看了网上很多人的,但是没有一个能解决我的情况

最后解决的配置是这样的:

package top.sehnsucht.common.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @Description:
 * @Author: Cai
 * @CreateTime: 2021/10/9
 * ~~(^_^)~~
 */

@Configuration
public class WebConfig implements WebMvcConfigurer {
    
    


    @Autowired
    @Qualifier(value = "loginInterceptor")
    private HandlerInterceptor handlerInterceptor;

    /**
     * 注册拦截器
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    
    
        InterceptorRegistration registration = registry.addInterceptor(handlerInterceptor);
        //拦截路径
        registration.addPathPatterns("/**");
        //放行路径
        registration.excludePathPatterns(
                "/你自己的路径"

                ,"/swagger**/**"
                ,"/webjars/**"
                ,"/v2/**"
                ,"/favicon.ico"
        );

        WebMvcConfigurer.super.addInterceptors(registry);
    }
}

主要是这两个
/swagger**/**/v2/**

参考:
https://blog.csdn.net/xyh930929/article/details/109537258
https://blog.csdn.net/Ju3tinZz/article/details/115762426
https://blog.xujiuming.com/ming/14d110a5.html

猜你喜欢

转载自blog.csdn.net/Dueser/article/details/120764209