Search code examples
jsonspringrestservice

Spring Service to talk to another Spring service


I am new to Spring boot and was wondering how to have services talk to another service.

I am making a wholesale order json and the information would go to both a billing log and an item repository. I have a Controller and a Service to receive the wholesale order, but how do I add it to both those repositories? Billing Log and Item have Controller -> Service -> Repository. I was thinking to make the service object static so I can call the service by the controller, but have seen that it could be a bad idea. Is there a general way on how to make spring services talk to each other to save in their respective repos?


Solution

  • I wanted a Service to modify a repository that is within another Service. I solved this by autowiring public static services in the main application of spring-boot. This allows services to call other service's public methods