springboot整合swagger
来源:互联网 发布:农村淘宝店开店条件 编辑:程序博客网 时间:2024/06/05 07:27
项目源码:http://download.csdn.net/download/a295277302/9943725
添加jar依赖
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.5.0</version></dependency><dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.5.0</version></dependency>
之后添加类 SwaggerConfig
@Configuration@EnableSwagger2@ComponentScan("com.htf.controller")public class SwaggerConfig { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.htf.controller")) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { ApiInfo apiInfo = new ApiInfoBuilder().title("Spring Boot Sample REST APIs") .description("The APIs here demonstrate creating a service built with Spring Boot") .license("MIT") .licenseUrl("http://opensource.org/licenses/MIT") .contact("htf") .version("1.0") .build(); return apiInfo; }}
如果整合了Shiro/spring security
添加网页访问过滤的话 必须要将
/v2/api-docs,/swagger-resources这两个给过滤掉,
spring oauth2
以Shiro为例
//开放swagger资源 startfilterMap.put("/v2/api-docs", "anon");filterMap.put("/webjars/**", "anon");filterMap.put("/swagger-resources/**", "anon");filterMap.put("/swagger-ui.html", "anon");//开放swagger资源 end
阅读全文
1 0
- springboot整合swagger
- springboot整合swagger
- SpringBoot整合Swagger
- SpringBoot整合swagger
- SpringBoot整合Swagger
- Swagger与SpringBoot的整合
- springboot+mybatis+resteasy+swagger整合
- Swagger与SpringBoot的整合
- Springboot整合Swagger学习笔记
- springboot整合mybatis,swagger ui
- springmvc或者springboot整合swagger
- swagger 与 springboot 的整合实战
- springboot整合swagger UI 、spring-data-JPA
- SpringBoot开发案例之整合Swagger篇
- SpringBoot整合Swagger自动生成API文档
- SpringBoot开发案例之整合Swagger篇
- springboot + swagger
- springboot + swagger
- python day04
- Java——Java集合Collections工具类
- List User Messages:列出用户消息
- 史上最全的 struts2 面试题
- cocos2dx-lua绑定自定义c++类(一)
- springboot整合swagger
- hdu 6121 Build a tree (图论)
- 链家笔试题总结
- mysql 存储过程及事务实例
- RPC原理
- CSS布局模型----第八系列
- C语言指针和数组
- 学生做国际义工:时尚背后有多少坑
- 2.1 Hello Unity