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

请教一个HIBERNATE在SPRING中的写法,具体如下
在SPRING的applicationContext.xml中,有这么一段内容:
  <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 定义SessionFactory必须注入DataSource-->  
  <property name="dataSource"><ref local="dataSource"/></property>  
  <property name="mappingResources">  

<list>  
  <!--以下用来列出所有的PO映射文件-->
<value>classpath:com/liufeng/bean/Customer.hbm.xml</value>
</list>  
  </property>  
<property name="hibernateProperties">  
  <props>  
<!--此处用来定义hibernate的SessionFactory的属性:  
不同数据库连接,启动时选择create,update,create-drop-->  
  <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>  
  <prop key="hibernate.hbm2ddl.auto">update</prop>  
  </props>  
  </property> 
</bean>

红色粗体字标出来的,是运行过程中报错的地方,文件识别不了;想请教一下,这个地方写相对路径应该怎么写。

------解决方案--------------------
不用那个什么classpath
------解决方案--------------------
楼上正解

如果你要用那个classpath:的话
就把那个属性值改为mappingDirectoryLocations
下面用classpath:/com/liufeng/bean即可一次指定这个路径下的所有.hbm.xml文件
------解决方案--------------------
XML code
<value>com/liufeng/bean/Customer.hbm.xml </value>