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: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.Configuration
上面是报错信息
下面是xml文件的配置
<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.MySQLDialect
</prop>
<!--设置二级缓冲-->
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<!--设置二级缓冲,打开查询缓冲-->
<prop key="hibernate.cache.use_query_cache">true</prop>
<!--设置显示Hibernate操作的SQL语句-->
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>
com/model/WyGame.hbm.xml
</value>
</list>
</property>
</bean>
下面是jar包的导入
在spring-orm.jar包中有org.springframework.orm.hibernate3包,且包中有LocalSessionFactoryBean.class文件
请大神指导下上面的问题是怎么回事呢~~~~
------解决方案--------------------
你看下你lib下面有没有 hibernate-annotations.jar 和 hibernate-commons-annotations.jar 有的话 删掉 然后重新部署项目试试