打开大摇大摆的UI会给Micronaut带来404

问题描述 投票:0回答:1
按照此处的文档-https://micronaut-projects.github.io/micronaut-openapi/1.3.4/guide/index.html

我将我的build.gradle配置为包括如下编译时间任务,用于生成摇摇欲坠的Yaml-

tasks.withType(JavaCompile){ options.encoding = "UTF-8" options.compilerArgs.add('-parameters') options.fork = true options.forkOptions.jvmArgs << '-Dmicronaut.openapi.views.spec=rapidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop' }

这是我的application.yaml的样子-

micronaut: server: port: 9090 cors: enabled: true router: static-resources: swagger: paths: classpath:META-INF/swagger mapping: /swagger/** redoc: paths: classpath:META-INF/swagger/views/redoc mapping: /redoc/** rapidoc: paths: classpath:META-INF/swagger/views/rapidoc mapping: /rapidoc/** swagger-ui: paths: classpath:META-INF/swagger/views/swagger-ui mapping: /swagger-ui/**

[就像文档所说的,我也用Application.java注释,如下所示-

package com.api.backend; import io.micronaut.runtime.Micronaut; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.info.Contact; import io.swagger.v3.oas.annotations.info.Info; @OpenAPIDefinition( info = @Info( title = "API Backend", version = "0.0", description = "API backend" ) ) public class Application { public static void main(String[] args) { Micronaut.run(Application.class); } }

完成所有这些操作后,当我尝试打开http://localhost:9090/swagger/api-backend-0.0.yaml时,它将打开生成的开放API规范yaml。但是,如果尝试打开http://localhost:9090/swagger-ui/,则会得到404

任何人都可以帮助我解决问题或提出替代方案吗?

java swagger swagger-ui micronaut micronaut-openapi
1个回答
0
投票
所有步骤对我来说都是正确的。

您能否在构建项目后检查,是否在工件中的META-INF / swagger / views / swagger-ui下创建了index.html文件。

从maven的角度来看,运行mvn compile后,我们在目标文件夹下看到了这一点:目标/类/ META_INF / swagger / views / swagger-ui

© www.soinside.com 2019 - 2024. All rights reserved.