1.0 创建Swagger配置类
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket webApiConfig(){
return new Docket(DocumentationType.SWAGGER_2)
.groupName("webApi") .apiInfo(webApiInfo()) .select()
.paths(Predicates.not(PathSelectors.regex("/admin/.*")))
.paths(Predicates.not(PathSelectors.regex("/error.*"))) .build();
}
private ApiInfo webApiInfo(){
return new ApiInfoBuilder() .title("网站-课程中心API文档")
.description("本文档描述了课程中心微服务接口定义")
.version("1.0")
.contact(new Contact("Helen", "http://atguigu.com", "55317332@qq.com")) .build();
} }
1.1 在启动类添加
@ComponentScan(basePackages = {"扫描包的路径"})