6 ms·
How's does it compare to Google Guice? Are there any benifits of using a lightweight DI Engine over Spring?
by FlyingSnake 14y ago
How's does it compare to Google Guice? Are there any benifits of using a lightweight DI Engine over Spring?
- sgolestane 14y agoOn top of dependency injection out of the box Spring offers a lot more, like: Transaction Management, an MVC framework, JDCB templates, ...
- peeters 14y agoThe 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).
- Radu 14y agoYes, 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.
- peeters 14y agoAbsolutely 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.
- nvarsj 14y ago> Are there any benifits of using a lightweight DI Engine over Spring? Well yeah, several. You don't have to depend on a huge API (spring-core and everything else needed for spring-di) just to get one piece of functionality. You can avoid using XML as application logic. You can avoid singletons-as-default-behavior and mutable beans all over the place. It will likely be faster.