Answer the question
In order to leave comments, you need to log in
How to correctly make interactions between modules in Java Spring?
I want to learn how to write java microservices. There is a project on which I want to organize all this. But the project is not big; 40 people use it. Now it is a monolith. On the Internet, I found that for such small projects as mine, not microservices are made, but a microservice monolith. Broke the project into microservices (11 in total). One of which is working with Amosrm, and the second is the main one who creates some records in the database and analyzes them. Modules do not communicate with each other with Rest, but directly call the controller method of another module. So it turns out that the amo module must interact with the main module and vice versa. How to include these modules in gradle? and how, in general, should modules interact in such an architecture? Otherwise, if I connect amo in the main module and vice versa, it throws an error:
Circular dependency between the following tasks:
:amocrm:compileJava
\--- :datadeal:compileJava
\--- :amocrm:compileJava (*)
dependencies { //datadeal
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation project(':amocrm')
}
dependencies { //amocrm
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation project(':datadeal')
}
@Controller
@AllArgsConstructor
public class OrderControllerImpl implements OrderController {
private final OrdersService ordersService;
@Override
public void sendOrder(Long id) {
ordersService.sendOrder(id);
}
}
Answer the question
In order to leave comments, you need to log in
Good afternoon.
I will assume that you still have implemented not a microservice monolith, but a monolithic architecture. You just divided the monolithic application into modules and included them in gradle. On the other hand, do you need a microservice monolith or a microservice in general if the application is quite small and only 40 people use it.
If we are just talking about the interaction of modules of a monolithic application, then in the corresponding gradle file of the module, connect the desired module and import the necessary services, classes, etc.
The main thing to note is that there is no cyclic dependency that you have indicated here:
Circular dependency between the following tasks:
:amocrm:compileJava
\--- :datadeal:compileJava
\--- :amocrm:compileJava (*)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question