上下文初始化失败:创建名为'entityManagerFactoryBean'的bean时出错

时间:2018-01-02 21:01:00

标签: spring hibernate jpa spring-data spring-data-jpa

我在我的本地尝试了Spring + JPA + Hibernate,但是我遇到了错误。我试图改变排除dom4j的版本(如上所述here),但没有用。

这是错误

2018-01-03 02:01:40 ERROR DispatcherServlet:502 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactoryBean' defined in ServletContext resource [/WEB-INF/configuration/recon-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/io/STAXEventReader
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634).........

下面是POM.xml enter image description here

和Servlet.xml

enter image description here

我试图删除dom4j,但它不起作用,并且还将hibernate版本从5.2.12更改为5.0.12,但看起来它不起作用。

提前感谢您的建议。

1 个答案:

答案 0 :(得分:0)

这是安装: Caused by: java.lang.ClassNotFoundException: org.dom4j.io.STAXEventReader 此外,您的pom依赖项部分看起来过于复杂。