使用ssh三大框架和整合出现的异常

本文介绍了在使用Hibernate和Spring框架整合过程中遇到的异常及其解决办法,包括PropertyNotFoundException和HibernateQueryException等,并提供了Struts与Spring整合时配置异常的解决方案。

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

Hibernate出现的异常:
1. org.hibernate.PropertyNotFoundException: Could not locate getter method for property [cn.itcast.domain.Customer#custId]
原因:在实体类中没有生成get方法。导致的
Hibernate和Spring框架整合时出现的异常:
org.springframework.orm.hibernate5.HibernateQueryException: cst_customer is not mapped [from cst_customer];
原因:使用hql时候查询时候,写的是查询表,但是hibernate操作的是映射对象,而不是表,把表名改成映射文件里的对象名就可以了

Struts整合Spring框架配置报异常:
atcom.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory
Class: com.opensymphony.xwork2.spring.SpringObjectFactory
File: SpringObjectFactory.java
Method: getClassInstance
Line: 209 - com/opensymphony/xwork2/spring/SpringObjectFactory.java:209:-

Caused by: java.lang.NullPointerException at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:209)
原因:
1.lib中我多导入包的原因:去掉struts2-spring-plugin-2.1.8包就可以,因为没有用到spring。
2.如果是用spring了,没加监听器,也会出现这种情况,这个时候在WEB.XML中假如jar包就可以了。
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
我是为了图方便粘贴的jar包过来,还没有配置Spring框架,只是想测试我的struts2框架是否成功,然后就一直报这个错,找的头都大了,后来根据错误提示,一点点去找到的,难受
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值