在pom.xml文件中添加Maven依赖

<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>

新建一个config包,并在其下面添加Swagger配置类SwaggerConfig.java。

@Configurable
@EnableSwagger2
public class SwaggerConfig { @Bean
public Docket CreateRestApi(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().
apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()).build();
} public ApiInfo apiInfo(){
return new ApiInfoBuilder().build();
}
}

在application启动类添加

@EnableSwagger2

启动页面测试

浏览器中访问http://localhost:8001/swagger-ui.html#/

最新文章

  1. iOS开发之App间账号共享与SDK封装
  2. JavaScript学习笔记-数组
  3. 关于update set from where
  4. linux系统:rm-rf执行以后,怎么办?我来教你恢复文件。
  5. Snagit 12 – 功能强的老牌截图软件
  6. linux下改变文件的字符编码
  7. spring maven pom
  8. C++模板:二分查找
  9. HDU 3032 Nim or not Nim? (sg函数求解)
  10. Composite C1是一个.Net平台上开源专业的CMS开源项目
  11. git &amp; github 同步文件
  12. Ubuntu 下wifi掉线
  13. zabbix3.4.7 饼图显示问题
  14. cubieboard网络设置
  15. 分页组件vue和jsp版本
  16. B-spline Curves 学习之B样条曲线的导数(8)
  17. C#里面的枚举与位或运算符 一个枚举变量存入多个值
  18. AOP拦截日志报错llegalStateException: It is illegal to call this method if the current request is not in asynchronous mode
  19. 【Huffman树贪心+优先队列】POJ3253-Fence Repair
  20. 【转】使用Jmeter对Websocket进行压力测试

热门文章

  1. beyond compare解决特殊字符无法输出、多sheet页无法对比以及文件太大超出系统内存问题的Excel转txt脚本
  2. ERROR: source database &quot;template1&quot; is being accessed by other users
  3. MSYS2 编译环境配置
  4. hibernate的load和get有什么作用
  5. postman做接口测试 application/x-www-form-urlencoded 格式与json格式互转
  6. Python - Django - 序列化
  7. [LeetCode] 200. Number of Islands 岛屿的数量
  8. [LeetCode] 354. Russian Doll Envelopes 俄罗斯套娃信封
  9. mongodb 切换wiredtiger
  10. Python:self理解