Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: null
Caused by: org.hibernate.MappingException: Association references unmapped class: null这是我的配置文件,不知哪里有错误,那位高手给看一下,谢谢!!!
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">    <bean id="dataSource"
     class="org.springframework.jdbc.datasource.DriverManagerDataSource">
     <property name="driverClassName">
     <value>oracle.jdbc.driver.OracleDriver</value>
     </property>
     <property name="url">
     <value>jdbc:oracle:thin:@127.0.0.1:1521:BYSJ</value>
     </property>
     <property name="username">
     <value>bysj</value>
     </property>
     <property name="password">
     <value>bysj</value>
     </property>
    </bean>
    <bean id="mySessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingResources">
  <list>
<value>entity/hbm/Academe.hbm.xml</value><!--映射文件路径 -->
            <value>entity/hbm/Admin.hbm.xml</value>
            <value>entity/hbm/Classes.hbm.xml</value>
            <value>entity/hbm/CoachTeacher.hbm.xml</value>
            <value>entity/hbm/Committee.hbm.xml</value>
            <value>entity/hbm/EchoCondition.hbm.xml</value>
            <value>entity/hbm/Proportion.hbm.xml</value>
            <value>entity/hbm/Specialty.hbm.xml</value>
            <value>entity/hbm/Student.hbm.xml</value>
            <value>entity/hbm/SyndicTeacher.hbm.xml</value>
            <value>entity/hbm/Task.hbm.xml</value>
            <value>entity/hbm/Teacher.hbm.xml</value>
            <value>entity/hbm/Topic.hbm.xml</value>
            <value>entity/hbm/TopicDemand.hbm.xml</value>
            <value>entity/hbm/TopicType.hbm.xml</value>
  </list>
</property>
<property name="hibernateProperties">
   <props>
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<bean id="academeDAO" class="dao.impl.AcademeDAOImpl">
<property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="adminDAO" class="dao.impl.AdminDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="classesDAO" class="dao.impl.ClassesDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="coachTeacherDAO" class="dao.impl.CoachTeacherDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="committeeDAO" class="dao.impl.CommitteeDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="echoConditionDAO" class="dao.impl.EchoConditionDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="proportionDAO" class="dao.impl.ProportionDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="specialtyDAO" class="dao.impl.SpecialtyDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="studentDAO" class="dao.impl.StudentDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="syndicTeacherDAO" class="dao.impl.SyndicTeacherDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="taskDAO" class="dao.impl.TaskDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="teacherDAO" class="dao.impl.TeacherDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="topicDAO" class="dao.impl.TopicDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
<bean id="topicDemandDAO" class="dao.impl.TopicDemandDAOImpl">
    <property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>
</beans>

解决方案 »

  1.   

    'mySessionFactory'  的问题吧
      

  2.   

    <value>entity/hbm/Academe.hbm.xml </value> <!--映射文件路径 --> 
                <value>entity/hbm/Admin.hbm.xml </value> 
                <value>entity/hbm/Classes.hbm.xml </value> 
                <value>entity/hbm/CoachTeacher.hbm.xml </value> 
                <value>entity/hbm/Committee.hbm.xml </value> 
                <value>entity/hbm/EchoCondition.hbm.xml </value> 
                <value>entity/hbm/Proportion.hbm.xml </value> 
                <value>entity/hbm/Specialty.hbm.xml </value> 
                <value>entity/hbm/Student.hbm.xml </value> 
                <value>entity/hbm/SyndicTeacher.hbm.xml </value> 
                <value>entity/hbm/Task.hbm.xml </value> 
                <value>entity/hbm/Teacher.hbm.xml </value> 
                <value>entity/hbm/Topic.hbm.xml </value> 
                <value>entity/hbm/TopicDemand.hbm.xml </value> 
                <value>entity/hbm/TopicType.hbm.xml </value> 
     你看看映射文件中的 class 的路径是不是正确
      

  3.   

    <value>entity/hbm/Academe.hbm.xml </value> <!--映射文件路径 --> 
                <value>entity/hbm/Admin.hbm.xml </value> 
                <value>entity/hbm/Classes.hbm.xml </value> 
                <value>entity/hbm/CoachTeacher.hbm.xml </value> 
                <value>entity/hbm/Committee.hbm.xml </value> 
                <value>entity/hbm/EchoCondition.hbm.xml </value> 
                <value>entity/hbm/Proportion.hbm.xml </value> 
                <value>entity/hbm/Specialty.hbm.xml </value> 
                <value>entity/hbm/Student.hbm.xml </value> 
                <value>entity/hbm/SyndicTeacher.hbm.xml </value> 
                <value>entity/hbm/Task.hbm.xml </value> 
                <value>entity/hbm/Teacher.hbm.xml </value> 
                <value>entity/hbm/Topic.hbm.xml </value> 
                <value>entity/hbm/TopicDemand.hbm.xml </value> 
                <value>entity/hbm/TopicType.hbm.xml </value> 
    你看看是不是你的class中的路径的问题