Swagger2配置

/**
 *
 */
@Configuration
@EnableSwagger2
@Profile({"dev"}) // 指定只能在开发环境中使用
public class Swagger2Config {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.web.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().build();
    }
}
原文地址:https://www.cnblogs.com/james641/p/12759105.html