你看过文档to transition to 2.0?
@Bean
public Docket swaggerSpringMvcPlugin() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("business-api")
.select()
//Ignores controllers annotated with @CustomIgnore
.apis(not(withClassAnnotation(CustomIgnore.class))
// and by paths
.paths(paths())
.build()
.apiInfo(apiInfo())
.securitySchemes(securitySchemes())
.securityContext(securityContext());
}
您应该能够使用RequestHandlerSelectors筛选您使用以下谓词需要 API的
- 类注释,如例显示上述
withClassAnnotation
- 方法的注释(用于过滤操作)
withMethodAnnotation
- 由基础包装
basePackage
我怀疑你已经想出了如何让它与XML配置工作(在这种情况下,这个问题的标题是不正确的)。如果你需要更多的例子,还有很多demos and examples。如果您还有其他问题,问题跟踪器可能比我们不经常使用的stackoverflow.com更好。
感谢您的回复。我伸出了另一个论坛,你回答(谢谢)。问题在于spring(2.0.5)中的tokenendpoint将endpoint/oauth/token暴露给所有的http方法。无法弄清楚如何过滤出特定的方法。 – picsram
这个'.apis(not(withClassAnnotation(CustomIgnore.class))'不适用于我的2.2.2。 –
@MikhailBatcer'@ ApiIgnore'已经被支持。'not(....)'技术只是如果你不想使用springfox提供的注释,无论如何,如果它不起作用,请创建一个问题。 –