How to share entity between REST service between two microservices?

后端 未结 3 1735
被撕碎了的回忆
被撕碎了的回忆 2021-02-14 16:04

I have created two micro-services using java. I need to make a REST api call from service A to service B. The data sent will be in JSON format. Using jax-rs I need to create ent

3条回答
  •  北海茫月
    2021-02-14 16:49

    I'd say it depends on the situation. If you use a shared package, this will introduce a coupling between the two projects. This makes sense, if both of the project build up on the same data classes and therefore will have the same dto objects to work with. Ideally you would have your own nexus which simplifies the usage of the shared artefact. Otherwise, if only a few classes are redundant I probably would implement it in each sevice separately, which decouples them too.

    I am afraid that you need to decide which one the right solution is for your project.

提交回复
热议问题