Spring-fox接口文档笔记

使用 Swagger 时如果碰见版本更新,只需要更改Swagger的描述文件即可。但是在频繁地更新项目版本时很多开发人员认为即使修改描述文件(yml 或 json)也有一定的工作负担,久而久之就直接修改代码,而不去修改描述文件了,这样基于描述文件生成接口文档也就失去了意义。 由于Spring的流行,Marty Pitt 编写了一个基于Spring 的组件swagger-springmvc。Spring-fox 就是根据这个组件发展而来的全新项目。Spring-fox 是根据代码生成接口文档,所以正常的进行更新项目版本,修改代码即可,而不需要跟随修改描述文件。Spring-fox 利用自身 AOP 特性,把 Swagger 集成进来,底层还是Swagger。但是使用起来确方便很多。所以在实际开发中,都是直接使用 spring-fox。

官网地址:

https://github.com/springfox/springfox
  • spring-fox依赖
<!--spring-fox依赖-->

<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>
  • spring-fox与springBoot整合时依赖

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>
@SpringBootApplication
@EnableSwagger2 //使用swagger注解
@EnableWebMvc
public class SwaggerDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(SwaggerDemoApplication.class, args);
    }

}

//访问地址 http://localhost:8080/swagger-ui/index.html

  博客:孤独&烙印的博客_CSDN博客-springSecurity,spring-fox,vue领域博主

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

孤独&烙印

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值