本文介绍了更新到最新版本后替换@EnableSwagger2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我迁移到最新的 springfox-swagger2
版本 2.10.0
但看起来 @EnableSwagger2
已被弃用.
I migrated to latest springfox-swagger2
version 2.10.0
but looks like @EnableSwagger2
is deprecated.
为了在 Spring Boot 项目中启用 Swagger,我应该使用什么注解?@EnableSwagger2WebMvc
?
What annotation should I use in order to enable Swagger into Spring Boot project? @EnableSwagger2WebMvc
?
推荐答案
@EnableSwagger2 在 swagger 2.10+ 中被弃用
@EnableSwagger2WebMvc 在 3.0.0+ 中被弃用
有趣但真实:)
现在你可以在 Spring 5 MVC 中使用以下依赖
Now you can use following dependency with Spring 5 MVC
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
和
- 移除对 springfox-swagger2 的显式依赖
- 删除@EnableSwagger2 注释
- 添加 springfox-boot-starter 依赖
见:https://github.com/springfox/springfox
这篇关于更新到最新版本后替换@EnableSwagger2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!