Is it fine to have a @Service
annotated class calling another @Service
annotated class? Or it is a bad practice?
Eg.:
JavaScript
x
@Service
public class MyService {
// ...
@Autowired
private MyOtherService myOtherService;
// ...
}
Advertisement
Answer
It is not any restriction calling a service from another one. Unless you make circular dependency between services.
Circular dependency : https://en.wikipedia.org/wiki/Circular_dependency
Circular dependency in spring : https://www.baeldung.com/circular-dependencies-in-spring