Search code examples
struts2struts2-spring-plugin

Struts2 + Spring, is the Spring Plugin required?


I'm replacing the service tier in an existing older Struts2 project with Spring service beans developed for another project.

I'd like to just @Inject these service beans into my Action classes.

Is it required to use Struts' Spring Plugin? Or can I add Spring into my Struts web application like I would any other (ContextLoaderListener, applicationContext.xml, context:component-scan)?

Am I missing some reason why the Struts Spring plugin helps me in another way?

Many thanks!


Solution

  • Well you can do the most of the things what you have described in your question as Services layer is completely out of view for the S2 and Struts2 do not care how you are creating your Service layer instances and other things.

    Benefits i am seeing of using Struts2-Spring plugin is to delegate creation of Struts2 related things to Spring like Action classes creation,Interceptors,Results etc.

    My Suggestion is to use the plugin as you are going to use the Spring in your application so its very good and flexible as well powerful to use the power of Spring DI to create required objects needed by S2 else S2 will use its own data creation factory to create framework component.