1) Spring is able to handle dependency loops in many cases, especially when not using constructor injections.
2) Despite this. You should absolutely avoid this design. It breaks many principles of good architecture:
- Components should only have access to as few other components as needed. Demeter's Law
- Separation of concerns. A service should not at the same time handle business logic, and presentation.
- Abstraction levels. A service should not handle both a logical view of data, and a persistence view of it.
Breaking such principles may lead to bad situations such as:
- Inability to follow code paths (a single request will go through 12 services in an order that is hard to understand and relies on many levels of conditional logic).
- Difficulty to know which components rely on each-other.
- Strongly coupled code (changing a low level service will lead to changes in high level services).
The advantages you gain from such a design are very small (you just avoid a few @Autowired
annotations) and are not worth the risk.