Skip to content

07 springfox swagger2

Alan edited this page Apr 12, 2018 · 9 revisions

工具及汇总api转发设计图

工具和api转发设计图

Spring Cloud程序快速接入SpringFox-swagger2

  1. pom.xml中添加依赖
<!-- swagger --> 
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.8.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-bean-validators</artifactId>
    <version>2.8.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.8.0</version>
</dependency>
  1. 和Application配置启动类同级添加Swagger配置类 参考代码

    需要根据实际情况修改的代码:

.apis(RequestHandlerSelectors.basePackage("com.demo.controller"))// 扫描该包下的所有需要在Swagger中展示的API,@ApiIgnore注解标注的除外 3. 文档注解使用参考

注解使用参考

Clone this wiki locally