出错提示信息:
严重: 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
我加入的包如下图,
严重: 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
我加入的包如下图,
严重: 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要怎么解决。
dom4j的jar包没有导入
对的,没找到这个解析XML的的东西 当然解析XML失败。
<?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>
看这句话就知道了
楼主还是把出问题的代码贴出来,这样谁知道哪出错了,