Swagger2配置 @Configuration @EnableSwagger2 public class SwaggerConfig { //创建接口文档 @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() //扫描com.au.sa包下文件 .apis(RequestHandlerSelectors.basePackage("com.softdev.welco.controller")) //扫描@Api注解的类 .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) //扫描@ApiOperation注解的方法 .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .paths(PathSelectors.any()) .build(); } //接口文档的描述 private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("迎新模块") .description("XXX模块") .version("1.0") .build(); }