【问题标题】:Can't find @EnableSwagger annotation找不到@EnableSwagger 注释
【发布时间】:2017-11-14 08:51:51
【问题描述】:
我只是想记录我的 Spring Rest 应用程序。按照如何使用 springfox 我在 pom.xml 中添加了一个依赖项:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
jar 已正确下载,但我无法在任何地方找到 @EnableSwagger2 注释。
【问题讨论】:
标签:
java
spring
maven
spring-boot
swagger
【解决方案1】:
这里也一样。 springfox.documentation.swagger2 jar 在 springfox-core:2.7.0 中不存在它们存在于我之前使用它的 2.6.1 的先前版本中。我正在回退到 2.6.1。
查看他们的 2.7.0 发行说明以查看是否有任何您需要的错误修复可能不是一个坏主意:https://github.com/springfox/springfox/releases/tag/2.7.0
更新:@EnableSwagger 实际上在 springfox-swagger2-2.7.0.jar 而不是 springfox-core.jar 中。
【解决方案2】:
它应该在springfox.documentation.swagger2.annotations 包中。
【解决方案3】:
尝试使用
@EnableSwagger2WebFlux 和 @EnableSwagger2WebMvc
具有以下依赖关系
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webflux</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
【解决方案4】:
我用的是swagger 2.8.0,@EnableSwagger2无法解析,然后,我del本地maven仓库,然后重新导入,就ok了!