Springboot Oauth2 集成Swagger2权限验证实战

Swagger是什么?能干什么?在这就不展开讲解了。本文主要讲解如何集成OAuth2的Password模式权限验证,验证接口是否具有权限。

引入依赖

io.springfox
springfox-swagger2
2.9.2


io.springfox
springfox-swagger-ui
2.9.2

2.SwaggerConfig配置

package com.entfrm.core.swagger.config;

import com.entfrm.core.base.config.GlobalConfig;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.OAuthBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.Arrays;
import java.util.Collections;

/**

上一篇:WebApi OAuth2身份认证


下一篇:OAuth2报错:java.lang.NoSuchMethodError: org.springframework.data.redis.connection.RedisConnection.set(