找不到@EnableSwagger注释

时间:2017-06-12 19:00:52

标签: java spring maven spring-boot swagger

我只想记录我的春季休息应用程序。关于如何使用springfox,我在pom.xml中添加了依赖项:

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.7.0</version>
</dependency>

正确下载了jar,但我无法找到@ EnableSwagger2注释。

4 个答案:

答案 0 :(得分:3)

同样在这里。 springfox-core中不存在springfox.documentation.swagger2 jar: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。

答案 1 :(得分:0)

它应该在springfox.documentation.swagger2.annotations包中。

答案 2 :(得分:0)

尝试使用 @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>

答案 3 :(得分:-1)

我使用swagger 2.8.0,@ EnableSwagger2无法解析,然后,我删除了本地maven存储库,然后将其导入,就可以了!

相关问题