openapi - 将项目作为项目中的模块移动后,打开 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 作为模块移动可能需要任何其他更改,我在互联网上搜索了很长时间,但找不到任何帮助。
解决方案
带有 REST 注释的接口是否在不同的包中?如果是,那么这就是问题所在。
推荐阅读
- python - Docker 输入文件并保存在输出中
- python - 在 Python 中,为什么类方法会覆盖实例方法?
- javascript - 从 HTML 中过滤代理
- swift - 如何修复类型“()”不能符合“视图”;只有结构/枚举/类类型可以符合协议
- jersey - 泽西岛“找不到合适的构造函数”用于子资源
- vuejs2 - 当我在 axios 调用中有提交时,为什么我的有效负载未定义
- javascript - 动态循环遍历 javascript 数组
- lldb - 使用 lldb 在内存中查找字节序列
- java - 如何在运行 Spring Boot 应用程序时重新加载初始数据?
- canvas - 三.JS | GLSL 使用画布作为着色器统一纹理