1. 使用hql语句时的报错: org.hibernate.hql.internal.ast.QuerySyntaxException: USER is not mapped 报错解决
原因:
这个错误的原因在于from后面接的应该是类名(User),而不是表名(USER)。
我的hql语句是
String hql = "from user";
解决:
所以正确的写法是String hql = "from User"
2. 在hbm.xml中的table名报错: Cannot resolve table 根据提示assign data Source,发现dataSource中提示default or no dataSource
原因:
经过检查发现是我之前更改了jdbc的驱动但之前那个没有删除导致,一直引入的都是错误的驱动
解决:
参照https://www.cnblogs.com/yinze/p/13894069.html
3. 配置文件中的报错:Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/action-servlet.xml]
原因:
原因在于contextConfigLocation属性是否配置写错了
解决:
检查struts-config.xml
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="ContextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
</plug-in>
ContextConfigLocation的头字母“C"是大写的。改成小写,重启系统。异常信息没有了。
4. applicationContext.xml中的sessionFactory配置错误:Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property ‘dataSource‘: no matching editors or conversion strategy found
原因:
dataSource的引用错误
解决:
把value改成ref即可
5. Spring注入一直失败,bean写的也没有问题
可能原因:
在struts-config.xml文件中配置action是没有吧actionBean的创建交给spring来管理
解决:
将type的值改为以下即可
type="org.springframework.web.struts.DelegatingActionProxy"
6. 使用hibernateTemplate报错 getsession方法找不到
原因:
import的hibernate版本(hibernate3)与pom中导入的hibernate版本(hibernate4)不一致
hibernateTemplete只有在hibernate3以下支持,在hibernate4以上不支持,
原因是hibernate4已经开始支持事务管理会与hibetnateTemplete冲突
解决:
在pom.xml中将hibernate版本更改为hibernate3.X(我改成了3.5.1-Final)即可
s1sh(struts1+spring+hibernate)整合过程中遇一些的问题
原文:https://www.cnblogs.com/wzh-blogs/p/13962164.html