Add in the configuration interface of swagger
Predicates.or(RequestHandlerSelectors.basePackage(basePackage),RequestHandlerSelectors.basePackage(basePackage2) )
public Docket createRestApi() {
log.info("======================== 当前环境是否开启Swagger:" + SwaggerSwitch + " ========================");
return new Docket(DocumentationType.SWAGGER_2)
.securitySchemes(securitySchemes())
.securityContexts(securityContexts())
//配置是否启用Swagger,如果是false,在浏览器将无法访问,默认是true
.enable(SwaggerSwitch)
//apiInfo: 添加api详情信息,参数为ApiInfo类型的参数,这个参数包含了第二部分的所有信息比如标题、描述、版本之类的,开发中一般都会自定义这些信息
.apiInfo(apiInfo())
.select()
//apis: 添加过滤条件,
//加了ApiOperation注解的类,才生成接口文档
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//包下的类,才生成接口文档
// .apis(RequestHandlerSelectors.basePackage(basePackage))
.apis(Predicates.or(
RequestHandlerSelectors.basePackage(basePackage),
RequestHandlerSelectors.basePackage(basePackage2)
))
.paths(PathSelectors.any())
.build();
}