Skip to content

Struts Spring Hibernate Integration

Struts with Spring:
Spring with Struts scenario: (Integrating Spring with other web frameworks – Struts)
We can acquire a particular web framework such as Struts, while at the same time being able to enjoy the benefits afforded by Spring in other areas such as data access, declarative transaction management, and flexible configuration.
To INTEGRATE your Struts 1.x application with Spring, you have two options:
Configure Spring to manage your Actions as beans, using the ContextLoaderPlugin, and set their dependencies in a Spring context file.
Subclass Spring’s ActionSupport classes and grab your Spring-managed beans explicitly using a getWebApplicationContext() method.
 Reference: 0)

Spring with Hibernate:

Spring configuration file will have:

Pom.xml Dependencies:

Need to mention Spring Dependencies and Hibernate Dependencies as below:

        <!– Spring framework –>
        <!– Spring AOP dependency –>

<!– Hibernate annotation –>

Spring Config file should have the below code:

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
    <property name="transactionManagerName" value="java:/TransactionManager"/>

or if you are using Websphere, then

<bean id=”transactionManager”  class=”org.springframework.transaction.jta.WebSphereUowTransactionManager” />