So far, I've used Spring exclusively for my DI. However, it is pretty tedious, and since I pretty much only use the explicit binding of Spring, I end up with oodles of XML configuration.
I think I'm going to try Guice for a while and see how it goes. It should streamline my usage of DI (since I started doing similar things with Spring anyway), which would be peachy. It doesn't, however, take care of configuration, which Spring sort of did for me. So I'm watching the tutorial to figure out how to integrate Guice and then use (insert some other tool here) for management of configuration.
I'll post more when I know it.
Updated : I think I now understand the tradeoffs between what I like about Guice and what I like about Spring.
Guice (ratings are on scale of (+) suck (1) to awesome (5), (-) from shucks (1) to FOAD (5)):
- +++ Focused on DI (sort of, they threw in a support for dev/prod envs)
- ++++ Splits concerns of component configuration (which port do I listen on? What's my log directory?) and component wiring (dependency management between components)
- +++++ Wiring can be flexibly composed from auto-wiring and manual wiring
- +++ (Unsure) Seems to be far better at supporting Unit/Mock testing
- ? Some configuration support (Dynamic enum support, could be neat?)
- --- Requires you to use Guice annotations
Spring (same scale):
- ++ Spring Annotations are mostly external usage
- +++ Doesn't require you to tie your code to Spring
- ---- Wiring together modules from different projects with their own configuration is, at best, hackish (at work and home I use imports to handle the problem, with some dynamic application contexts passed in on CLI)
- ---- XML configuration is very verbose, and since the auto-wiring has sucked from experience, I use explicit XML
- --- Configuration and wiring are merged
I think the primary hesitancy I have with Guice is using their Annotations. However, we've treated the Spring configuration as code for quite a long time now. We have quite a bit of Spring configuration as well, easily more than would be added through simple annotations. Also, Guice seems to allow for building a framework via it's annotations and contexts to make thread safety easier, both by making it more explicit and automated.
Overall, since it seems like you could use Guice for wiring and Spring for the Web Kitchen Sink Framework, or Spring for both, but Guice seems inherently simpler. I'm sold enough to try it out. Now I need a toy project to try it out on. Hmmm.