简体   繁体   English

Jhipster 无法生成实体,因为应用程序没有在网关中配置数据库

[英]Jhipster The entity cannot be generated as the application does not have a database configured in gateway

I am using jhipster version v6.5.0我正在使用jhipster版本v6.5.0
When I am creating microservice gateway it asks for a database with the following error.当我创建微服务网关时,它要求一个带有以下错误的数据库。

ERROR: Error: The entity cannot be generated as the application does not have a database configured!错误:错误:无法生成实体,因为应用程序没有配置数据库!

Actually First I created a gateway with database and entities will work after my microservices are not running.实际上,首先我创建了一个带有数据库的网关,并且在我的微服务未运行后实体将起作用。 That means it works as monolithic and I could see all JPA servicers in the gateway.这意味着它可以作为单片机工作,我可以在网关中看到所有 JPA 服务商。 Swagger API showing fine. Swagger API 显示正常。 But menu from Entities not using microservices.但是来自实体的菜单不使用微服务。

.yo-rc.json .yo-rc.json

{
"generator-jhipster": {
    "promptValues": {
        "packageName": "com.xxx.gate",
        "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.5.0",
    "applicationType": "gateway",
    "baseName": "myGate2",
    "packageName": "com.xxx.gate",
    "packageFolder": "com/xxx/gate",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "hazelcast",
    "enableHibernateCache": false,
    "websocket": "spring-websocket",
    "databaseType": "no",
    "devDatabaseType": "no",
    "prodDatabaseType": "no",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "XXXXXXXX",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "lumen",
    "clientThemeVariant": "dark",
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
        "en"
    ],
    "blueprints": []
}

Please help请帮忙

JHipster gateway does not persist entities, it's the responsibility of the microservices. JHipster 网关不持久化实体,它是微服务的责任。 This is why you are not able to generate entities in your gateway, the gateway will only import your microservices entities to generate frontend for them.这就是为什么您无法在网关中生成实体的原因,网关只会导入您的微服务实体来为它们生成前端。

Rather than converting your monolith into a gateway, you should import your existing entities into a new service.您应该将现有实体导入新服务,而不是将您的单体转换为网关。

I tried several possibilities.我尝试了几种可能性。 After changing my angular service class below it starts working as expected(calling microservice rather going directly to gateway).更改下面的 angular 服务 class 后,它开始按预期工作(调用微服务而不是直接进入网关)。

Generated生成

public resourceUrl = SERVER_API_URL + 'api/countries';

Changed to变成

public resourceUrl = SERVER_API_URL + 'services/myservice/api/countries';

I am not sure that is the correct way that Jhipster expected.我不确定这是 Jhipster 所期望的正确方式。 I have noticed that in gateway SORS filter too.我也注意到在网关 SORS 过滤器中。

If you have any git project build with Angular Entities it would be great to understand better.如果您有任何使用 Angular 实体构建的 git 项目,那么更好地理解会很棒。

Thank you for your attention and help.感谢您的关注和帮助。

Have you solved this issue?你解决了这个问题吗? and how?如何? I am having the same issue as yours, the user entity is not created on the database, actually the whole database configuration properties are not provided, and the Spring Data dependencies are not in the classpath.我遇到了和你一样的问题,没有在数据库上创建用户实体,实际上没有提供整个数据库配置属性,并且 Spring 数据依赖项不在类路径中。 Even if you add the Spring Data dependency and the configuration properties, nothing gets created on the database.即使您添加 Spring 数据依赖项和配置属性,也不会在数据库上创建任何内容。 Please help.请帮忙。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM