SpringBoot [ 5.集成Swagger-Bootstrap-UI] - 目录
文章目录
首先Swagger它是一个API文档工具,可以通过各种注解生成接口文档,Model文档,但是我在使用Swagger的时候,觉得实用性并不高,一个机会接触到了基于Swagger开发的Swagger-Bootstrap-UI,觉得很好用;
1.引入依赖
<!-- springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-swagger2.version}</version>
<!-- swagger-models剔除原因: 1.5.20版本swagger-models 读取失败, 使用1.5.21替代 -->
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- swagger-models -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger.models.version}</version>
</dependency>
<!-- swagger-bootstrap-ui -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap-ui.version}</version>
</dependency>
2.配置类
SwaggerConfiguration 类,其实这个类得配置,是有很多东西可以配置,但是我这里得话按照官方文档只配置了标题,详情,访问地址,版本。
package com.mantou.boot.config.swagger;
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.s