添加依赖:
com.github.xiaoymin knife4j-spring-boot-starter2.0.2
编写配置类
@Configuration @EnableSwagger2 @EnableKnife4j @ConditionalOnProperty(value = {"knife4j.enable"}, matchIfMissing = true) public class Swagger2Config { @Bean(value = "indexApi") public Docket indexApi() { return new Docket(documentationType.SWAGGER_2) .groupName("前台API分组") .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.example.swagger.user")) .paths(PathSelectors.any()) .build(); } @Bean(value = "adminApi") public Docket adminApi() { return new Docket(documentationType.SWAGGER_2) .groupName("后台API分组") .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.example.swagger.admin")) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("swagger-bootstrap-ui RESTful APIs") .description("swagger-bootstrap-ui") .termsOfServiceUrl("http://localhost:8999/") .contact("developer@mail.com") .version("1.0") .build(); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)