You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JHipster 7.0.1基于JDL生成项目后实体Swagger UI未生成问题咨询

解决方案

1. 修正JDL语法错误

你的JDL配置块中clientFramework angular后缺少逗号,会导致配置解析异常,修正后的JDL配置部分如下:

application {
  config {
    baseName myApp,
    applicationType monolith,
    packageName com.myapp,
    authenticationType jwt,
    prodDatabaseType postgresql,
    clientFramework angular,
    enableSwaggerCodegen true
  }
  entities *
}

enableSwaggerCodegen是API优先开发模式下用于生成接口代码的配置,和Swagger UI展示接口无关,不需要该功能可直接删除这行配置。

2. 检查登录权限

JHipster 7.x版本默认实体对应的REST接口需要管理员权限才能访问,Swagger UI只会展示当前登录用户有权限调用的接口。请使用默认管理员账号(账号:admin,密码:admin)登录系统后,再刷新Swagger UI页面即可看到实体相关接口。

3. 校验Springdoc配置

JHipster 7.x已使用Springdoc替代原有的Springfox作为Swagger实现,请检查src/main/resources/config/application-dev.yml中是否存在以下配置,缺失则补充:

springdoc:
  paths-to-match: /api/**
  packages-to-scan: com.myapp.web.rest
  swagger-ui:
    enabled: true
    path: /swagger-ui.html

确认packages-to-scan的路径和你项目的Controller包路径(默认是com.myapp.web.rest)一致,保证Springdoc能扫描到实体对应的接口类。

4. 检查Controller注解与依赖

  • 查看src/main/java/com/myapp/web/rest下的实体Controller类,确认类上已添加@Tag注解,没有该注解Springdoc不会将接口纳入Swagger UI展示。
  • 检查pom.xml中是否存在Springdoc相关依赖,缺失则补充后重新编译启动:
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-webmvc-core</artifactId>
</dependency>
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
</dependency>

内容的提问来源于stack exchange,提问作者ajayramesh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.18 18:54:04