I’m building a new web application that uses Linux, Apache, Tomcat, Wicket, JPA/Hibernate, and MySQL. My primary need is Dependency Injection, which both Spring and Guice can do well. I think I need transaction support that would come with Spring and JTA but I’m not sure.
The site will probably have about 20 pages and I’m not expect huge traffic.
Should I use Spring or Guice?
Feel free to ask and followup questions and I’ll do my best to update this.
If you like the “do-it-all-in-Java” philosophy that Wicket follows, then you might prefer Guice over Spring. There is no XML configuration in Guice – it is all done using the Guice
Moduleclass.For example, your Wicket
WebApplicationclass might look something like this:The
GuiceComponentInjectorcomes from the wicket-guice extension. Here’s the Module:In this example,
Greetingsis an interface implemented by a concreteGreetingRepositoryclass. When Guice needs to inject aGreetingsobject, it will satisfy the dependency with aGreetingRepository.I have put together a sample project that demonstrates how to build a Wicket/Guice application for Google App Engine. You can safely ignore the App Engine specifics and focus on how the Wicket-Guice integration works.