出错提示信息:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: edu.hut.bookstore.Book
Caused by: org.hibernate.MappingException: Association references unmapped class: edu.hut.bookstore.Book
我加入的包如下图,

解决方案 »

  1.   

    Caused by: org.hibernate.MappingException: Association references unmapped class: edu.hut.bookstore.Book提示信息非常明确,说得是实体映射出错了。就是 unmapped 你的这个Book类 和 相对应的 xml 在 spring 里的配置不正确。你没贴 我也看不到。
      

  2.   

    改动了一点点,出现这个问题。
    严重: Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [
    /WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Co
    uld not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception i
    s java.lang.NoClassDefFoundError: org/dom4j/DocumentException
    Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalS
    essionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
    Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException要怎么解决。
      

  3.   

    Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException
    dom4j的jar包没有导入
      

  4.   


    对的,没找到这个解析XML的的东西 当然解析XML失败。
      

  5.   

    以下是发动配置文件,帮忙看下:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
    </property>
    <property name="url"
    value="jdbc:sqlserver://127.0.0.1:1433;databaseName=XSCJ;">
    </property>
    <property name="username" value="sa"></property>
    <property name="password" value="123456"></property>
    </bean> <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.SQLServerDialect
    </prop>
    <prop key="show_sql"></prop>
    </props>
    </property>
    <property name="mappingResources">
    <list>
    <value>/edu/hut/bookstore/model/Book.hbm.xml</value>
    <value>/edu/hut/bookstore/model/User.hbm.xml</value>
    <value>/edu/hut/bookstore/model/Order1.hbm.xml</value>
    <value>/edu/hut/bookstore/model/Orderitem.hbm.xml</value>
    <value>/edu/hut/bookstore/model/Catalog.hbm.xml</value>
    </list>
    </property>
    </bean> <bean id="userDAO" class="edu.hut.bookstore.dao.impl.UserDAO">
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <bean id="userService" class="edu.hut.bookstore.service.impl.UserService">
    <property name="userDAO">
    <ref bean="userDAO" />
    </property>
    </bean>
    <bean id="userAction" class="edu.hut.bookstore.action.UserAction">
    <property name="userService">
    <ref bean="userService" />
    </property>
    </bean>
    </beans>
      

  6.   

    Caused by: org.hibernate.MappingException: Association references unmapped class: edu.hut.bookstore.Book
    看这句话就知道了
      

  7.   

    就是说,你的dom4j的jar包加入到项目去了没
      

  8.   

    应该是这个配置:<value>/edu/hut/bookstore/model/Book.hbm.xml</value>
    楼主还是把出问题的代码贴出来,这样谁知道哪出错了,