Swagger生成接口文档

  • 在pom.xml中引入依赖
   <dependency>
      <groupId>com.spring4all</groupId>
        <artifactId>swagger-spring-boot-starter</artifactId>
        <version>1.8.0.RELEASE</version>
      </dependency>

  • 在应用主类中增加@EnableSwagger2Doc注解
@SpringBootApplication
@EnableSwagger2Doc
public class Springboot2Swagger2Application {

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

默认情况下就能产生所有当前SpringMVC加载的请求映射文档

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

  • 参数配置示例
swagger.enabled=true
swagger.title=spring-data-jpa module
swagger.description=Starter for swagger 2.x
swagger.license=Apache License, Version 2.0
swagger.licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.html
swagger.termsOfServiceUrl=https://github.com/dyc87112/spring-boot-starter-swagger
swagger.contact.name=mqXu
swagger.contact.url=https://www.jianshu.com/u/822585e5c69a
swagger.contact.email=moqi1977@gmail.com
swagger.base-package=com.springboot.mybatis.controller
swagger.base-path=/**
swagger.exclude-path=/error, /ops/**

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Swagger简介 在系统设计的时候,各个应用之间往往是通过接口进行交互的。因此接口的定义在整个团队中就变得尤为重...
    whitejava阅读 9,379评论 1 3
  • swagger的由来 随着互联网技术的发展,现在的网站架构基本都由原来的后端渲染,变成了:前端渲染、先后端分离的形...
    墨寒_3338阅读 7,962评论 1 1
  • swagger的由来 随着互联网技术的发展,现在的网站架构基本都由原来的后端渲染,变成了:前端渲染、先后端分离的形...
    hangover_bfc9阅读 3,211评论 0 0
  • 锡木司地铁站与上海站平行 出租车司机载我去火车站 晚点 我在车窗延伸出来的木板上反行驶方向爬着。
    音左LEFT阅读 1,137评论 0 0
  • 仅以此篇,纪念我在芭蕾的日子。也是想说,每一个努力向上的人都值得尊重。 婆娑芭蕾演绎丰盈淋漓人生,抖落一路芬芳 ...
    对话仝小仝阅读 4,097评论 5 3