春季-将applicationcontext.xml和.hbm文件放在哪里?

我正在学习spring hibernate zk stack,并在this tutorial之后做我的第一个任务
我将applicationContext.xml放入webapp / WEB-INF,并将.hbm.xml放入资源/映射
但是我不知道为什么我的hbm文件不断显示找不到我的pojos.

在github https://github.com/kossel/firstzk

我有这个结构

applicationContext.xml

  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <!-- set other Hibernate properties in hibernate.cfg.xml file -->
        <property name="configLocation" value="classpath:/com/iknition/firstzk/hibernate/hibernate.cfg.xml" />
    </bean>

hibernate.cfg.xml

    <mapping resource="com/iknition/firstzk/hibernate/Company.hbm.xml" />
    <mapping resource="com/iknition/firstzk/hibernate/Contact.hbm.xml" /> 

Company.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.iknition.firstzk.beans">
    <class name="Contact" table="contact">
        <id name="idcontact" column="idcontact" type="integer">
            <generator class="increment" />
        </id>
        <property name="name" column="name" type="string" />
        <property name="email" column="email" type="string" />
        <many-to-one name="company" column="companyId" class="com.iknition.firstzk.beans.Company" outer-join="true" />
    </class>
</hibernate-mapping>

Contact.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.iknition.firstzk.beans">
    <class name="Contact" table="contact">
        <id name="idcontact" column="idcontact" type="integer">
            <generator class="increment" />
        </id>
        <property name="name" column="name" type="string" />
        <property name="email" column="email" type="string" />
        <many-to-one name="company" column="companyId" class="com.iknition.firstzk.beans.Company" outer-join="true" />
    </class>
</hibernate-mapping>

更新:

>我也参考contact.hbm.xml,我错过了把它放在这里.
>通过“为什么为什么我的hbm文件一直显示找不到我的pojos”,我的意思是,当我尝试构建该应用程序时,我一直收到以下错误:“由:org.hibernate.MappingException:找不到实体类:com.iknition. firstzk.beans.Contact“我已经多次更改了那些配置文件的位置,并且仍然遇到相同的错误.

最佳答案
我认为您必须像这样一对一地指定mappingLocations:

<property name="mappingLocations">
  <util:list>
    <value>hibernate/Company.hbm.xml</value>
    <value>hibernate/Contact.hbm.xml</value>
  </util:list>
</property>

相关文章

这篇文章主要介绍了spring的事务传播属性REQUIRED_NESTED的原...
今天小编给大家分享的是一文解析spring中事务的传播机制,相...
这篇文章主要介绍了SpringCloudAlibaba和SpringCloud有什么区...
本篇文章和大家了解一下SpringCloud整合XXL-Job的几个步骤。...
本篇文章和大家了解一下Spring延迟初始化会遇到什么问题。有...
这篇文章主要介绍了怎么使用Spring提供的不同缓存注解实现缓...