日期:2014-05-18  浏览次数:20716 次

Spring2.0 + hibernate + struts遇到的比较奇怪影射问题
最近刚用到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>

------解决方案--------------------
直接
<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了
------解决方案--------------------
帮顶,新手,还不懂。
------解决方案--------------------
3楼的仁兄说的没错,hibernate.cfg.xml个完全可以拿掉,直接在applicationContext.xml加载...hbm.xml这问题就应该能解决了.
但是保留hibernate.cfg.xml也不是不可以,我原来也这么做过,没出现楼主说的问题,不知道楼主的web.xml是怎么配的? 根据错误提示,是web.xml没配置好...
------解决方案--------------------
那是版本间的问题,不能向上兼容
------解决方案--------------------
分无条件给我吧。