I have a Spring project which contains ~50 components. Unfortunately, one of the classes caused an issue of cyclic dependency in Maven. Here's the story:
I added a new component to my Spring project. Let's call it Apple
for now. It has a @Bean
called AppleWatch
. One of the implementations was that Apple
lived (depended) on another component: Foxconn
, so that AppleWatch
could call a method in a Bean called CheapLabor
.
At the meantime, CheapLabor
depended on another component: Corning
. It needed GorillaGlass
to be able to work overtime.
Things were pretty good until the moment Corning
realizes that it wants to save money by making the similar amount of glasses according to the Apple's market need. So it tries to call a method getCurrentMarketOrders()
in AppleWatch
. To do so, I autowired the bean AppleWatch
into the class GorillaGlass.java
. Then...
Boom! Cyclic dependency error!
So, any suggestion on what should I do for Apple
and/or Corning
?