三大框架整合

本文详细介绍了如何在项目中整合Spring、Struts2和Hibernate框架,并通过配置web.xml和struts.xml实现Spring的支持。同时,提供了解决部署过程中可能出现的内存溢出问题的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.添加Spring支持,选择spring,spring web库和spring-persistence库


2.添加Struts2,struts2 spring


3.添加Hibernate支持,选择使用spring的配置文件,不创建sessionFactory


4.在src目录下添加log4j.properties


5.修改web.xml,添加<context-param>和<listener>配置:
 <!-- spring的配置 -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/classes/applicationContext.xml
    </param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

6.修改struts.xml,添加从对象工厂常量,值为spring,添加一个devMode方便调试
<constant name="sturts.objectFactory" value="spring"/>
<constant name="struts.devMode" value="true" />


7.部署到tomcat,删除重复的8个jar包,剩下70个jar包



8.如果启动tomcat报内存溢出的错误:
        java.lang.OutOfMemoryError: PermGen space
     -XX:PermSize=256m
     -XX:MaxPermSize=256m
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值