大多数地方的swagger配置都是按照包路径索引的,在多系统场景下提供公共包的时候这种配置方式不太实用,官方有提供按照注解去找api接口的方式,
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
除此之外还有按类索引的
withClassAnnotation
@Bean
public Docket defaultApi2() {
Docket docket=new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
.build())
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build();
return docket;
}