hbm.xml文件不能被找到的错误


把原来能进行unit测试的程序放进tomcat,发现出了新故事,系统反馈:
java.io.FileNotFoundException: class path resource [com/haha/waplog/model/Blog. hbm.xmlcannot  be  opened  because  it  does  not exist...
显然,这是spring的配置文件有什么毛病,自己察看了一下,这个配置文件中是这么写的:

<bean id="WapLogSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="WaplogDataSource"/>
    <property name="mappingResources">
      <list>
        <value>com/haha/waplog/model/Blog. hbm.xml</value>
        <value>com/haha/waplog/model/blogitem. hbm.xml</value>
        <value>com/haha/waplog/model/category. hbm.xml</value>
        <value>com/haha/waplog/model/user. hbm.xml</value>
        <value>com/haha/waplog/model/blogComment. hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
      </props>
    </property>
</bean>

好像是这个问题:<property name="mappingResources">

在google上搜索:"class path resource" " cannot  be  opened" tomcat
居然幸运的有所斩获。

把上面那段调整成:
  <bean id="WapLogSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="WaplogDataSource"/>
    <property name="mappingLocations">
<value>classpath*:com/haha/waplog/**/*.hbm.xml</value>
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
      </props>
    </property>
  </bean>
就好了... 

你可能感兴趣的:(spring,tomcat,list,Google,测试)