spring-boot集成Springfox-Swagger2
程序员文章站
2022-06-07 18:21:27
...
spring-boot-springfox
效果图:
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.6.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.6.0</version> </dependency>
@Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket adminApi(){ return new Docket(DocumentationType.SWAGGER_2) .groupName("Admin API") .forCodeGeneration(true) .pathMapping("/") .select() .paths(paths()) .build() .apiInfo(apiInfo()) .useDefaultResponseMessages(false); } private Predicate<String> paths(){ return Predicates.and(PathSelectors.regex("/.*"), Predicates.not(PathSelectors.regex("/error"))); } private ApiInfo apiInfo(){ Contact contact = new Contact("lance", "https://github.com/leelance", "81222045@qq.com"); return new ApiInfoBuilder() .title("Document Api") .description("Spring-boot-Springfox Example") .license("Apache License Version 2.0") .contact(contact) .version("2.0") .build(); } }
项目完整路径:
https://github.com/leelance/spring-boot-all/tree/master/spring-boot-springfox
上一篇: nginx增添php basic验证
下一篇: MySQL视图之我见
推荐阅读
-
springcloud学习之路: (五) springcloud集成SpringCloudConfig分布式配置中心
-
asp.net core集成kindeditor实现图片上传功能
-
集成显卡3D加速怎么开启?
-
spring集成mybatis原理(spring和mybatis整合步骤)
-
Spring Boot集成Mybatis的实例代码(简洁版)
-
springboot2.x集成swagger的方法示例
-
Spring Security OAuth2集成短信验证码登录以及第三方登录
-
spring集成okhttp3的步骤详解
-
spring boot 与kafka集成的示例代码
-
在vue项目中集成graphql(vue-ApolloClient)