Spring2.0 + hibernate + struts遇到的比较奇怪影射问题

真的很小奚 2007-07-30 05:38:15
最近刚用到spring2.0一直用1.2了新东西要练习下
applicationContext.xml
配置sesionFactory
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="datasource">
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<prop key="show_sql">true</prop>
</props>
</property>
配置影射这里出问题了 只要不写以下代码
就没有问题 只要存在映射 不管提交什么 是否用到IOC的servlet 都抱错
type Status report

message Servlet action is not available

description The requested resource (Servlet action is not available) is not available.
不写影射 OR 使用Spring1.2 OR 使用hibernate.cfg.xml 也有同样问题只要配置影射就报错。。。。。。。。。。。。。郁闷ING有 玩过的指点下吧。
<property name="mappingResources">
<list>
<value>org/ssh/hibernate/Mdetail.hbm.xml</value>
<value>org/ssh/hibernate/Morder.hbm.xml</value>
list>
</property>
</bean>
...全文
376 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
梦想·王 2007-08-06
  • 打赏
  • 举报
回复
谢谢楼主给我分,本来我是开玩笑的,没想到楼主真的给了我分,我想这也是楼主对我的激励吧,我今后会更加努力的学习。最后再次感谢楼主。
真的很小奚 2007-07-31
  • 打赏
  • 举报
回复
那为什么只有在 配置了hibernate影射的时候才有问题呢??
难道只有 hibernate影射版本问题 同样是hibernate3.0的影射呀 只是换了spring2.0了
ruanjiantaotao 2007-07-31
  • 打赏
  • 举报
回复
那是版本间的问题,不能向上兼容
真的很小奚 2007-07-31
  • 打赏
  • 举报
回复
貌似 问题已经解决了
DELETE掉asm-2.2.3.jar与hibernate-annotations.jar这两个包 就没有问题了
求高手 给予解答为什么??
要不200分给谁 给我自己好象不行吧。
讨论有分
真的很小奚 2007-07-31
  • 打赏
  • 举报
回复
哎 都是指正我在spring配置hibernate 使用hibernate.cfg.xml的
怎么就没有关心 为什么影射会影响 到 action 的提交呢。
type Status report

message Servlet action is not available

description The requested resource (Servlet action is not available) is not available.

和上面我说的一样struts-config 没有错误 因为我试了去掉plug-in 正常
然后增加plug-in 报错 查找applicationContext.xml不配置hibernate影射正常

郁闷ING(spring2.0出现1.2正常)
真的很小奚 2007-07-31
  • 打赏
  • 举报
回复
开始我也这么认为是web.xml的问题 把web.xml struts-config.xml弄了N便 后来发现是
hibernate影射问题 如果不在applicationContext.xml写hibernate的影射
<property name="mappingResources">
<list>
<value>org/ssh/hibernate/Mdetail.hbm.xml</value>
<value>org/ssh/hibernate/Morder.hbm.xml</value>
</list>
没有任何问题

我用hibernate.cfg.xml是为了实验看能否出现同样问题(不配置影射关系没有问题),感谢几位的指点。
我使用spring2.0出现以上问题 1.2的没有问题。

因为在struts-config中
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
</plug-in>
所以struts-config没有错误的话就应该是applicationContext.xml的问题 我是一点一点实验出来发现是hibernate的影射有问题的。(hibernate在applicationContext.xml中两种配置方法都试过了)


期待那位玩过spring2.0指点下吧
zxh2208180 2007-07-31
  • 打赏
  • 举报
回复
3楼的仁兄说的没错,hibernate.cfg.xml个完全可以拿掉,直接在applicationContext.xml加载...hbm.xml这问题就应该能解决了.
但是保留hibernate.cfg.xml也不是不可以,我原来也这么做过,没出现楼主说的问题,不知道楼主的web.xml是怎么配的? 根据错误提示,是web.xml没配置好...
wengnet 2007-07-31
  • 打赏
  • 举报
回复
帮顶,新手,还不懂。
真的很小奚 2007-07-31
  • 打赏
  • 举报
回复
顶 顶 顶 200分都没人答呀??
谢谢帮顶有分
真的很小奚 2007-07-31
  • 打赏
  • 举报
回复
跪请各位大哥 看明白问题 谢谢 谢谢
在强调下 使用spring2.0时候只要配置 影射关系就报错
type Status report

message Servlet action is not available

description The requested resource (Servlet action is not available) is not available.

去掉
<property name="mappingResources">
<list>
<value>org/ssh/hibernate/Mdetail.hbm.xml</value>
<value>org/ssh/hibernate/Morder.hbm.xml</value>
</list>
</property> 就没有问题了 使用spring1.2没问题
我做了个实验 使用hibernate.cfg.xml的配置得到 相同结果只要不配置映射关系 一切OK
真的很小奚 2007-07-31
  • 打赏
  • 举报
回复
问题我已经解决了 我就是想知道为什么 ruanjiantaotao(Smart Tao) 说的有道理呀
在等等明天揭贴....................................
分对我没用我这级别好象是到了500左右的可用分就不+了
梦想·王 2007-07-31
  • 打赏
  • 举报
回复
分无条件给我吧。
大叔obnijeh 2007-07-31
  • 打赏
  • 举报
回复
报了个什么错。
Onelee 2007-07-30
  • 打赏
  • 举报
回复
直接
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>org/xx/bean/XXX.hbm.xml</value>
<value>org/xx/bean/XXX.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<prop key="hibernate.show_sql">
true
</prop>
</props>
</property>
</bean>

不需要用hibernate.cfg.xml了
真的很小奚 2007-07-30
  • 打赏
  • 举报
回复
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
在hibernatenate.cfg.xml中没有配置影射时正常
只要有
<mapping resource="org/ssh3/hibernate/Morder.hbm.xml"/>
就报错找不到servlet

spring2.0不熟 请用过同仁 指点 一二 谢谢

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧