为什么OpenAPI官方配置在编译时找不到符号

发布于 2025-02-03 20:08:55 字数 2613 浏览 2 评论 0原文

我正在使用Open API生成Swagger Docs,我按照官方文档进行构图:

package misc.config.openapi;

import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * https://springdoc.org/
 * https://github.com/springdoc/springdoc-openapi
 */
@Configuration
public class OpenApiConfig {

    @Bean
    public GroupedOpenApi fortuneApi() {
        return GroupedOpenApi.builder().group("Fortune").pathsToMatch("/fortune/**").build();
    }

}

这是文档页面。当我编译项目时,显示这样的错误:

> Configure project :dolphin-acientbay
/Users/xiaoqiangjiang/source/reddwarf/backend/retire
> Configure project :dolphin-post
/Users/xiaoqiangjiang/source/reddwarf/backend/retire
> Configure project :dolphin-template
/Users/xiaoqiangjiang/source/reddwarf/backend/retire
> Task :dolphin-common:compileJava FAILED
/Users/xiaoqiangjiang/source/reddwarf/backend/retire/dolphin-common/src/main/java/misc/config/openapi/OpenApiConfig.java:16: error: cannot find symbol
        return GroupedOpenApi.builder().group("Fortune").pathsToMatch("/fortune/**").build();
                                       ^
  symbol:   method group(String)
  location: class Builder
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dolphin-common:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
9 actionable tasks: 6 executed, 3 up-to-date

IntellijID没有提供任何错误提示,为什么不能编译该项目?我该怎么办来解决这个问题?我想念什么吗?这是我正在使用的依赖项:

api "org.springdoc:springdoc-openapi-ui:1.6.9"
api "org.springdoc:springdoc-openapi-webmvc-core:1.2.32"

I am using open api to generate the swagger docs, I follow the official documents to config like this:

package misc.config.openapi;

import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * https://springdoc.org/
 * https://github.com/springdoc/springdoc-openapi
 */
@Configuration
public class OpenApiConfig {

    @Bean
    public GroupedOpenApi fortuneApi() {
        return GroupedOpenApi.builder().group("Fortune").pathsToMatch("/fortune/**").build();
    }

}

this is the docs page. when I compile the project, shows error like this:

> Configure project :dolphin-acientbay
/Users/xiaoqiangjiang/source/reddwarf/backend/retire
> Configure project :dolphin-post
/Users/xiaoqiangjiang/source/reddwarf/backend/retire
> Configure project :dolphin-template
/Users/xiaoqiangjiang/source/reddwarf/backend/retire
> Task :dolphin-common:compileJava FAILED
/Users/xiaoqiangjiang/source/reddwarf/backend/retire/dolphin-common/src/main/java/misc/config/openapi/OpenApiConfig.java:16: error: cannot find symbol
        return GroupedOpenApi.builder().group("Fortune").pathsToMatch("/fortune/**").build();
                                       ^
  symbol:   method group(String)
  location: class Builder
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dolphin-common:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
9 actionable tasks: 6 executed, 3 up-to-date

the Intellij IDE did not give any error tips, why could not compile the project? what should I do to fixed this problem? Am I missing something? this is the dependencies I am using:

api "org.springdoc:springdoc-openapi-ui:1.6.9"
api "org.springdoc:springdoc-openapi-webmvc-core:1.2.32"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文