Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why to "Make autowired dependencies explicit"?

When I'm writing some spring xml configs, I personnally prefer to set default-autowire="byName".

But in Idea 14, the IDE warns me to "Make autowired dependencies explicit".

So here comes the question, whats the advantage of making spring bean wire explicit?

like image 760
alwinlin Avatar asked Oct 23 '25 15:10

alwinlin


1 Answers

The main advantage is that you can review the object graph in a centralized way, as opposed to having to chase down dependencies distributed across a bunch of class files, component scans and so forth.

The disadvantage is that your app config is larger. More code/config to manage.

Either style works. I tend to start with autowiring and then migrate toward explicit dependencies as the app gets larger.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!