1 引入相应的包:
io.springfox
springfox-swagger2
2.4.0
io.springfox
springfox-swagger-ui
2.4.0
2 创建配置类:
@EnableSwagger2
@Configuration
public class Swagger2Second {
private ApiInfo apiInfo(){
return new ApiInfoBuilder().
contact(new Contact("黑涩会大哥","www.baidu.com",null)).
title("鉴于风云 ").
description("监狱风云").
build();
}
@Bean
public Docket docket(){
return new Docket(DocumentationType.SWAGGER_2).
//选择器
select().
//api相关设置
apis(RequestHandlerSelectors.
//扫描包路径
basePackage("com.hh")).
//requestMapp匹配规则
paths(PathSelectors.any()).
build();
}
}
这样就ok了