美文网首页
3.使用swagger生成文档

3.使用swagger生成文档

作者: 长生藤 | 来源:发表于2019-03-22 08:47 被阅读0次

Swagger是一个开源软件框架,由大型工具生态系统支持,可帮助开发人员设计,构建,记录和使用RESTful Web服务。 虽然大多数用户通过Swagger UI工具识别Swagger,但Swagger工具集包括对自动文档,代码生成和测试用例生成的支持。

swagger的使用

  • 添加依赖
 <dependency>
            <groupId>com.spring4all</groupId>
            <artifactId>swagger-spring-boot-starter</artifactId>
            <version>1.8.0.RELEASE</version>
        </dependency>
  • 在启动类中添加注释
@SpringBootApplication
@MapperScan("com.springboot.mybatis.mapper")
@EnableSwagger2Doc
public class SpringBootMybatisApplication {

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

}
  • 在配置文件中添加swagger配置
swagger.enabled=true
swagger.title=spring-boot-mybatis module api
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=(此处自行填写url地址)
swagger.contact.email=(此处自行填写email)
swagger.base-package=com.springboot.mybatis.controller
swagger.base-path=/**
swagger.exclude-path=/error, /ops/**

*在启动类中启动项目,打开swagger地址


swagger UI.png

相关文章

网友评论

      本文标题:3.使用swagger生成文档

      本文链接:https://www.haomeiwen.com/subject/jovkvqtx.html