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

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自动生成文档的方式请前往

个人网站

转载于:https://my.oschina.net/u/4111324/blog/3042065

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值