some help needed with fixing circular dependencies
hey guys. can smb help me out with fixing circular dependencies?
This error doesnt even make sense, wtf?
18 Replies
⌛
This post has been reserved for your question.
Hey @bambyzas! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Well, make either importservice not depend on bgwservice or the other way around
um, yeah. but the thing is that i need both of them to depend on each other
There's a workaround, if you annotate a non-final field with @AutoWired instead of the constructor
But circular dependencies are a sign that there's something wrong with your classes
They shouldn't depend on each other
i removed some code, bc i needed to hide some sensitive stuff
but u can still see the logic and the dependency between these two services
What does BGW mean?
no idea 😦
I see a call to
bgwService.deleteAccountStatement
MAybe that should be in a different service that manages statements?
So you wouldn't have to call bgwservice?
This is application architecture and hard to tell with bits of code
I'd have to take a few hours, look at how it works and come up with a planyeah, i know. thanks for at least taking a look haha
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
The fact that BGWService has both a customerRepository and a paymentRepository screams bad design to me
but basically id need to redesign the services and how they depend on each other, right?
Big red flags right there
Usually you have services depend on one single repository, for the type that they're responsible for
why? because one service manages two repos?
And if they need to do anything else they need to go through another service
yeah, and not even related ones
bgwService.deleteAccountStatement does that call any of those repositories?
nope. just does http req
ok, other angle
createPaymentpaymentConfirmation
Why isn't that in a PaymentService?
And just depend on the PaymentService instead of the BGWService?
It's stuff like that, ask if it really belongs there
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.