假设我有 2 个微服务:Service1 和 Service2。他们每个人都有自己的数据库。Service1 有 EntityA,Service2 有 EntityB
EntityA {
Long id;
//other fields
EntityB entity;
}
EntityB{
//other fields
}
我正在使用 Spring 的 RestTemplate 来检索和保存数据。问题是:当从 Service1 的数据库中检索 EntityA 时,我没有 EntityB 的数据,因为它们保存在 Service2 的数据库中,我知道我应该通过 RestTemplate 进行休息调用以从 Service2 的数据库中检索 EntityB,但是两者之间的关系如何?实体 - EntityA 是否仍应在内部包含整个 EntityB 对象,即使其字段除 id 外大部分时间都为空?我错过了什么?先感谢您。
喵喔喔
www说
摇曳的蔷薇
相关分类