/** * */ @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(); } }