当前位置: 移动技术网 > IT编程>开发语言>Java > 详解SpringBoot结合swagger2快速生成简单的接口文档

详解SpringBoot结合swagger2快速生成简单的接口文档

2019年07月19日  | 移动技术网IT编程  | 我要评论

1. pom.xml中加入依赖

    <dependency>
      <groupid>com.spring4all</groupid>
      <artifactid>swagger-spring-boot-starter</artifactid>
      <version>1.8.0.release</version>
    </dependency>

2. 在启动类(即带@springbootapplication这个注解的类)上添加@enableswagger2doc注解

3. 在application.properties中配置如下

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/pbw123/spring-boot-demo
swagger.contact.name=mqxu
swagger.contact.url=https://www.jianshu.com/u/2f60beddf923
swagger.contact.email=2635225112@qq.com
swagger.base-package=com.springboot.mybatis.controller
swagger.base-path=/**
swagger.exclude-path=/error, /ops/**

经我多次尝试application.properties中不加任何swagger配置也可生成文档进行正常测试

另一种用swagger自动生成文档的方式请

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网