swagger
jar包
1 | |
2 | <dependency> |
3 | <groupId>io.springfox</groupId> |
4 | <artifactId>springfox-swagger2</artifactId> |
5 | <version>2.7.0</version> |
6 | </dependency> |
7 | <dependency> |
8 | <groupId>io.springfox</groupId> |
9 | <artifactId>springfox-swagger-ui</artifactId> |
10 | <version>2.7.0</version> |
11 | </dependency> |
1 | package com.atguigu.servicebase; |
2 | |
3 | import com.google.common.base.Predicates; |
4 | import org.springframework.context.annotation.Bean; |
5 | import org.springframework.context.annotation.Configuration; |
6 | import springfox.documentation.builders.ApiInfoBuilder; |
7 | import springfox.documentation.builders.PathSelectors; |
8 | import springfox.documentation.service.ApiInfo; |
9 | import springfox.documentation.service.Contact; |
10 | import springfox.documentation.spi.DocumentationType; |
11 | import springfox.documentation.spring.web.plugins.Docket; |
12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
13 | |
14 | //配置类 |
15 | 2 //swagger注解 |
16 | public class SwaggerConfig { |
17 | |
18 | |
19 | public Docket webApiConfig(){ |
20 | return new Docket(DocumentationType.SWAGGER_2) |
21 | .groupName("webApi") |
22 | .apiInfo(webApiInfo()) |
23 | .select() |
24 | //.paths(Predicates.not(PathSelectors.regex("/admin/.*"))) |
25 | .paths(Predicates.not(PathSelectors.regex("/error.*"))) |
26 | .build(); |
27 | |
28 | } |
29 | |
30 | private ApiInfo webApiInfo(){ |
31 | |
32 | return new ApiInfoBuilder() |
33 | .title("网站-课程中心API文档") |
34 | .description("本文档描述了课程中心微服务接口定义") |
35 | .version("1.0") |
36 | .contact(new Contact("java", "http://atguigu.com", "1123@qq.com")) |
37 | .build(); |
38 | } |
39 | } |