Can anyone compare Google Guice and Spring DI?

Can anyone list the pros and cons of Google guice over Spring DI? Both satisfies the dependency injection in one way or the other. In which cases we can go for google guice and in which cases we can go for Spring DI.


Well, I've used both for different things. I think a lot of it depends on preference.

I'm not going to come up with an exhaustive comparison here, because others have done so on the web. In my experience, Spring fits in better with the Java EE side of things (web apps and the like), and Guice fits in better in with other types of applications (such as in Eclipse). I will say that the arguments against Spring that discuss its "unwieldy" XML configuration are no longer true. As of Spring 3, application contexts can be (almost) completely configured using annotated Java classes if you so desire.

Also keep in mind that Guice is much newer than Spring and, to a certain extent, the development team was able to base their code from what Spring learned developing a DI framework. In Guice, there seems to be a lot more flexibility for more corner use cases (such as the @Assisted annotation for partial factory-based injection).

链接地址: http://www.djcxy.com/p/59368.html

上一篇: 使用闹钟管理器即使应用程序关闭?

下一篇: 任何人都可以比较Google Guice和Spring DI吗?