Re:Spring Dependency Injection Styles – Why I love Java base...
by sgolestane on Monday July 23, 2012 @12:02PM
(#4281609)
On top of dependency injection out of the box Spring offers a lot more, like: Transaction Management, an MVC framework, JDCB templates, ...
[ Parent
| on HN ]
Re:Spring Dependency Injection Styles – Why I love Java base...
by peeters on Monday July 23, 2012 @12:32PM
(#4281796)
The key phrase there being "out of the box". Guice does great transaction management, just pull in guice-persist. It integrates with servlets cleanly, just pull in guice-servlet.
The difference is mainly that Guice tries to be a library and Spring tries to be a framework. I, for one, like knowing that I'm not pulling in "the world" just to get dependency injection.
Guice at its core does one thing, and one thing well: dependency injection (and by extension, AOP). It does dependency injection far better than any Spring version I've used (see: constructor injection).
Re:Spring Dependency Injection Styles – Why I love Java base...
by Radu on Monday July 23, 2012 @03:43PM
(#4282702)
Yes, but sooner or later guice won't be enough and you'll use a framework anyway; then the integration mess begins.
With the configuration in code/profiles in Spring 3.1 I don't see any real-world advantage to using guice.
Re:Spring Dependency Injection Styles – Why I love Java base...
by peeters on Monday July 23, 2012 @05:40PM
(#4283182)
Absolutely not. When core Guice "isn't enough", I just grab one of the many great tools that integrate with Guice (Jersey is one example). My DI tool remains my DI tool, and I use a library that provides bindings for it.