首页 > 编程 > Java > 正文

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

2019-11-26 09:01:52
字体:
来源:转载
供稿:网友

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=trueswagger.title=spring-boot-mybatis module apiswagger.description=Starter for swagger 2.xswagger.license=Apache License, Version 2.0swagger.licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.htmlswagger.termsOfServiceUrl=https://github.com/pbw123/spring-boot-demoswagger.contact.name=mqXuswagger.contact.url=https://www.jianshu.com/u/2f60beddf923swagger.contact.email=2635225112@qq.comswagger.base-package=com.springboot.mybatis.controllerswagger.base-path=/**swagger.exclude-path=/error, /ops/**

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

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

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表