1.在pom.xml中加入Swagger2的依赖

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>${swagger.version}</version>
</dependency>

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>${swagger.version}</version>
</dependency>

 

2.创建Swagger2配置类

@Configuration
@EnableSwagger2
public class Swagger2 {
    @Bean
    public Docket createResApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("blog.manager.web.bff"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("博客管理系统")
                .description("RESTful API")
                .termsOfServiceUrl("")
                .version("1.0")
                .build();
    }
}
如图:

springBoot配置Swagger

3.运行效果图

springBoot配置Swagger

相关文章:

  • 2021-04-05
  • 2018-03-15
  • 2021-12-03
  • 2021-05-23
  • 2022-12-23
  • 2021-12-29
  • 2021-05-30
  • 2021-05-01
猜你喜欢
  • 2022-01-05
  • 2021-05-27
  • 2021-06-04
  • 2022-01-13
  • 2021-07-23
相关资源
相似解决方案