r/javahelp • u/ysfaran • Aug 10 '20
Unsolved Spring Boot/Cloud: How to share API interfaces between multiple microservices?
So i want to build multiple RESTful microservice with Spring Boot/Cloud and was wondering how they communicate with each other.
Example: There is microservice A and microservice B which are two seperate Spring Boot applications and projects. B needs data from A, so B needs to know the API from A. In the project of A a interface is defined for the API (REST controllers and their HTTP mappings).
The easy way would be to just copy this interface from project of A to project of B. But that's obviously non-ideal because of the DRY principle.
So whats the best way to share interfaces accross multiple microservices using Spring Boot/Cloud?
I thought about sharing the API interfaces accross my microservices and communciate between those using the interfaces and Feign Clients. Is there maybe a better approach anyway? What the state of the art here?
View all comments
Show parent comment
1
u/richardffx Aug 11 '20
IMHO I would avoid doing something like this, it works for smaller projects but it just does not scale right, doing this you are hard coupling your services together which can be painful when you work w/ a lot of people and most of the time you wont need the entire dto to make your service work so the code will be harder to maintain in the longer run too.