springboot 禁用swagger2
时间: 2023-05-08 09:58:47 浏览: 969
在使用SpringBoot开发Web应用过程中,swagger2是一种非常常用的工具,它能够自动生成API文档,使我们的开发更加便捷。但有时也许我们需要禁用swagger2,这时我们需要采取以下步骤:
第一步,从pom.xml文件中删除swagger2的依赖项,即注释掉下面的代码:
```xml
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
```
第二步,进入SpringBoot的启动类,找到`@EnableSwagger2`注解,并将它注释掉或者删除掉。
第三步,如果我们需要更彻底地禁用swagger2,我们还需要在配置文件(application.yml或application.properties)中添加下面的配置:
```yaml
springfox.documentation.swagger.v2.enabled: false
```
通过这些步骤,我们就可以很方便地禁用swagger2,使得项目中不再有API文档的展示。
阅读全文
相关推荐

















