package com.hy.config;

    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.spi.DocumentationType;
    import springfox.documentation.spring.web.plugins.Docket;
    import springfox.documentation.swagger2.annotations.EnableSwagger2;

    /*
    @author whm
    @date 2021/12/22
    /
    @EnableSwagger2 //启用Swagger2
    @Configuration //表示是Swagger的配置类
    public class SwaggerConfig {

    1. @Bean<br /> public Docket createRestApi() {<br /> return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo("1.0.0")).select().apis(RequestHandlerSelectors.basePackage("com.hy.controller")).paths(PathSelectors.any()).build();<br /> }
    2. private ApiInfo apiInfo(String version) {<br /> return new ApiInfoBuilder().title("api").version(version).build();<br /> }

    }