首页 > 解决方案 > 将项目作为项目中的模块移动后,打开 api swagger-ui 给出白标错误页面(404)

问题描述

我在 Spring Boot 中有一个工作项目,它是一个独立的应用程序。现在,为了模块化,我已经拆分了应用程序并将 api 放入一个模块中。之前 swagger-ui.html 页面可以正常工作,但在此之后,它就无法正常工作了。

我的 pom.xml 有这两个依赖项

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>1.5.1</version>
</dependency>
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-data-rest</artifactId>
    <version>1.5.1</version>
</dependency>

Application.java有以下代码

@Bean
@Profile("!prod")
public OpenAPI caffeAPIRegistry() {
    return new OpenAPI()
            .info(new Info().title("My Awesome API")
                    .description("Powering UI")
                    .version("v3.0.0")
                    .license(new License().name("google  Inc.,").url("https://google.com")));
}

父项目映射的 pom.xml 片段

<parent>
    <artifactId>API_Project</artifactId>
    <groupId>com.abc</groupId>
    <version>2.0.0.RELEASE</version>
</parent>

如果将 api 作为模块移动可能需要任何其他更改,我在互联网上搜索了很长时间,但找不到任何帮助。

标签: openapispringdocspringdoc-openapi-ui

解决方案


带有 REST 注释的接口是否在不同的包中?如果是,那么这就是问题所在。


推荐阅读