首页 > 解决方案 > jhipster 与 webflux - Swagger 不工作

问题描述

我收到 jhipster+webflux 的错误,网关应用程序错误(JWT)应用程序--> 注册表--网关(角度)--多个服务(webflux)http://localhost:8080/admin/docs

“类型”:“https://www.jhipster.tech/problem/problem-with-message”,“标题”:“未找到”,“状态”:404,“详细信息”:“404 NOT_FOUND”,“路径" : "/swagger-ui.html", "消息" : "error.http.404"

.yo-rc.json

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "org.abc.gateway",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.10.3",
    "applicationType": "gateway",
    "baseName": "gateway",
    "packageName": "org.abc.gateway",
    "packageFolder": "org/abc/gateway",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "no",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "mongodb",
    "devDatabaseType": "mongodb",
    "prodDatabaseType": "mongodb",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSwaggerCodegen": true,
    "jwtSecretKey": "XXXXXXXXXXXXXXXX",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1602227915588,
    "testFrameworks": ["gatling", "cucumber", "protractor"],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": ["en", "hi"],
    "blueprints": [],
    "reactive": true
  }
}

招摇初始化错误

java.lang.NoSuchMethodError: springfox.documentation.spi.service.contexts.ParameterContext.(Lspringfox/documentation/service/ResolvedMethodParameter;Lspringfox/documentation/builders/ParameterBuilder;Lspringfox/documentation/spi/service/contexts/DocumentationContext;Lspringfox/documentation /spi/schema/GenericTypeNamingStrategy;Lspringfox/documentation/spi/service/contexts/OperationContext;)V

我需要检查什么,才能使用 spring-Webflux 项目启用招摇。

标签: swaggerjhipsterjhipster-gateway

解决方案


我在 jhipster 项目中发现了一个问题:https ://github.com/jhipster/generator-jhipster/issues/12072#issuecomment-683282300

要解决这个问题 :

1-更新依赖项(删除旧的依赖项)

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-boot-starter</artifactId>
        <version>${springfox.version}</version>
        <exclusions>
            <exclusion>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-bean-validators</artifactId>
            </exclusion>
            <exclusion>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-bean-validators</artifactId>
        <version>${springfox.version}</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>${springfox.version}</version>
    </dependency>

2 - 在整个项目中将路径“/v2/api-docs”更新为“/v3/api-docs”(前+后)

3 -docs.component.html更改 URI

<iframe src="./swagger-ui/" width="100%" height="900" seamless
    target="_top" title="Swagger UI" class="border-0"></iframe>

4 - 我遇到了安全问题。我允许 swagger 资源允许 all inSecurityConfiguration 由于我在生产 spring 配置文件中禁用了 Swagger,这对我来说不是问题。


推荐阅读