gpt4 book ai didi

java - 即使将 Swagger 添加为 Maven 依赖项,也无法导入 @ApiParam 或 @ApiModelProperty 注释

转载 作者:行者123 更新时间:2023-12-05 03:36:46 33 4
gpt4 key购买 nike

我正在做一个项目,我们用 Swagger 记录后端的 API。我想为 Swagger 使用基于注释的配置。对于我使用 @Tag@Operation@ApiResponses 的 Controller 类,它们工作得很好,它们可以使用以下语句导入:

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;

但是,如果我尝试将 @ApiParam@ApiModel 添加到我的代码中,我将无法以任何方式导入它们。

在我的 POM.xml 中,我添加了 Swagger 作为以下依赖项:

<!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.1.11</version>
</dependency>

我在这里缺少什么?我尝试关注 this Baeldung article和示例代码,但是我无法让它工作。感谢您的帮助!

最佳答案

“问题”是 Springdoc使用了,最初我假设使用了 Springfox 或普通的 Swagger 2 依赖项,因为它没有从代码库中删除。

要解决这个问题,我们只需要添加正确的依赖项并使用新的注释,这些注释映射到旧的注释,如 explained here。 .

关于java - 即使将 Swagger 添加为 Maven 依赖项,也无法导入 @ApiParam 或 @ApiModelProperty 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69555126/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com