英文:
Relationships not saved with Microservices
问题
我一直在努力使我的关系在我将应用程序从单体应用转换为微服务时保存下来。我可以通过Web应用程序进行更新,但在刷新或查看数据库后,更改是不可见的。基本上什么都不会发生,尽管吐司表明编辑成功。在网关和微服务日志中都没有看到任何错误或警告。
PUT更新调用确实具有所选的拥有实体:
organisation: {
"id": "f43d61b1-3ba5-4891-a252-a5e0d73e4bbc",
"name": "内华达木质校长",
"status": "协同传输混合",
"location": "交互式增量",
"headcount": 7182,
"parent": {
"id": null,
"name": null,
"status": null,
"location": null,
"headcount": null,
"parentId": null
},
"parentId": null
}
organisationId: null,
personalInfo: {
"id": "0b76be08-4cbf-408d-ab03-3ba9a3add15d",
"dateOfBirth": "2023-07-11",
"network": "自行车铀集成",
"wallet": null
},
personalInfoId: null
但是,所有者实体的GET读取调用仍然是:
organisation: {
"id": null,
"name": null,
"status": null,
"location": null,
"headcount": null,
"parentId": null
},
organisationId: null,
personalInfo: {
"id": null,
"dateOfBirth": null,
"network": null,
"wallet": null
}
personalInfoId: null
我尝试过使用jhipster 7.9.3、v7.x_maintenance、8.0.0-beta.1以及最新的主要版本。但我没有找到类似的错误报告,所以我一定是做错了什么。
为了使单体应用的关系保存下来,我不得不确保所有我的实体都以相同的方式定义了id(UUID)。我尝试了这个方法,也依赖于所有情况下的默认id。
为了使应用程序在微服务和最新版本的8.0下生成和运行正确,我不得不从默认的jwt更改为ouath2,从vue更改为react。
这是我的简化的jdl文件:
application {
config {
applicationType gateway
authenticationType oauth2
baseName mynk
buildTool gradle
clientFramework react
clientTheme zephyr
devDatabaseType h2Memory
languages [en, fr]
nativeLanguage en
packageName ma.mynk.wallet
prodDatabaseType postgresql
serviceDiscoveryType consul
}
entities *
}
application {
config {
applicationType microservice
authenticationType oauth2
baseName walletService
buildTool gradle
devDatabaseType h2Memory
packageName ma.mynk.wallet.core
prodDatabaseType postgresql
serviceDiscoveryType consul
}
entities *
}
entity Wallet {
id UUID
phoneNumber String
tag String
firstName String
lastName String
email String
currency String
contractId String
}
entity PersonalInfo {
id UUID
dateOfBirth LocalDate
network String
}
entity Organisation {
id UUID
name String
status String
location String
headcount Integer
}
relationship OneToOne {
Wallet{personalInfo} to PersonalInfo
}
relationship ManyToOne {
Organisation{parent(name)} to Organisation
Wallet{organisation(name)} to Organisation
}
service * with serviceImpl
paginate * with pagination
我生成应用程序的方式如下:
jhipster jdl --skip-jhipster-dependencies --workspaces --monorepository ../docs/jdl/relationship.jdl
要运行所有内容:
docker compose -f src/main/docker/consul.yml up -d
docker compose -f src/main/docker/keycloak.yml up -d
然后在每个微服务下运行 ./gradlew
。
英文:
I've been struggling to get my relationships to be saved when I converted my application from a monolith to microservices. I can update them via the webapp but on refresh or viewing the database the change is not visible. Basically nothing happens even though the toast indicates that the edit was successful. I don't see any errors nor warnings in either the gateway and nor microservice logs.
The PUT update calls do have the selected owned entities:
organisation: {
"id": "f43d61b1-3ba5-4891-a252-a5e0d73e4bbc",
"name": "Nevada Wooden Principal",
"status": "synergize transmit Hybrid",
"location": "interactive incremental",
"headcount": 7182,
"parent": {
"id": null,
"name": null,
"status": null,
"location": null,
"headcount": null,
"parentId": null
},
"parentId": null
}
organisationId: null,
personalInfo: {
"id": "0b76be08-4cbf-408d-ab03-3ba9a3add15d",
"dateOfBirth": "2023-07-11",
"network": "Bicycle Uranium Integration",
"wallet": null
},
personalInfoId: null
But the GET read calls of the owner entity still have:
organisation: {
"id": null,
"name": null,
"status": null,
"location": null,
"headcount": null,
"parentId": null
},
organisationId: null,
personalInfo: {
"id": null,
"dateOfBirth": null,
"network": null,
"wallet": null
}
personalInfoId: null
I have tried with jhipster 7.9.3 , v7.x_maintenance, 8.0.0-beta.1, and latest version from main. But I did not find a similar bug being reported so I must be doing something wrong.
To get relationships to save for the monolith, I had to ensure I defined ids the same way for all my entities (id UUID). I tried this for microservices, and also relying on the default ids in all cases.
To get the application to generate and run correctly with microservices and the latest version of 8.0 I had to change from jwt default to ouath2 and from vue to react.
Here is my simplified jdl file:
application {
config {
applicationType gateway
authenticationType oauth2
baseName mynk
buildTool gradle
clientFramework react
clientTheme zephyr
devDatabaseType h2Memory
languages [en, fr]
nativeLanguage en
packageName ma.mynk.wallet
prodDatabaseType postgresql
serviceDiscoveryType consul
}
entities *
}
application {
config {
applicationType microservice
authenticationType oauth2
baseName walletService
buildTool gradle
devDatabaseType h2Memory
packageName ma.mynk.wallet.core
prodDatabaseType postgresql
serviceDiscoveryType consul
}
entities *
}
entity Wallet {
id UUID
phoneNumber String
tag String
firstName String
lastName String
email String
currency String
contractId String
}
entity PersonalInfo {
id UUID
dateOfBirth LocalDate
network String
}
entity Organisation {
id UUID
name String
status String
location String
headcount Integer
}
relationship OneToOne {
Wallet{personalInfo} to PersonalInfo
}
relationship ManyToOne {
Organisation{parent(name)} to Organisation
Wallet{organisation(name)} to Organisation
}
service * with serviceImpl
paginate * with pagination
I generate the application as follows:
jhipster jdl --skip-jhipster-dependencies --workspaces --monorepository ../docs/jdl/relationship.jdl
To run everything:
docker compose -f src/main/docker/consul.yml up -d
docker compose -f src/main/docker/keycloak.yml up -d
and then ./gradlew
under each microservice.
答案1
得分: 0
我确实缺少 microservice
指令:
microservice * with walletService
我曾经在某处看到,它会通过将实体列在应用程序的一部分 (entities *
) 来自动生成,但我可能误解了那个。
英文:
I was indeed missing the microservice
directive:
microservice * with walletService
I had read somewhere that it would be auto generated by listing the entities as part of the application (entities *
) but I must have misunderstood that.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论