Re:Spring Dependency Injection Styles – Why I love Java base...
by jsolson on Monday July 23, 2012 @11:32AM
(#4281436)
I'm on the polar opposite end of this. We component scan everything we can, and I couldn't be happier. I have never once been surprised by what annotation based config assembled for me.
So, approaches may vary.
I only half agree that this is a limitation. I use as little component scanning as possible. I think it's better to scan for the configuration classes (hopefully there aren't many) and explicitly define the rest. I like this for two reasons, first for speed and second because everything is defined in a fairly central place. I can't tell you how many times I've been surprised by annotation based configuration.
Personally I like Spring's Java Configuration over Guice's. It's more flexible for my needs. Although I suppose that an argument could be made that that's the problem: configuration over convention.
I'm glad you mentioned the Guice style @inject is available with Spring now. I wasn't aware of that.