使用jpa和spring时的配置错误

时间:2015-02-23 10:50:05

标签: jpa

当我通过创建动态Web项目在eclipse Helios中运行我的应用程序时,我收到以下错误。我还使用cxf从wsdl自动生成类。

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/persistence.xml]

我的persistence.xml位于src文件夹中的META-INF中: 请帮忙解决错误。 我使用JPA和spring从数据库中检索。

1 个答案:

答案 0 :(得分:0)

嗯,您的应用程序中有一种机制可以加载弹簧上下文。在您谈论Web应用程序时,我猜您的上下文会在web.xml中加载。 在你的web.xml中会有一个类似的部分:

<context-param> 
  <param-name>contextConfigLocation</param-name> 
  <param-value>/META-INF/*.xml</param-value> 
</context-param> 

此模式也与您的persistence.xml匹配。

所以我们将其更改为:

 <param-value>/WEB-INF/springContext*.xml</param-value>  

现在,spring只会加载以springContext开头并以xml结尾的上下文文件。

不幸的是,你的问题没有详细解释你的应用,所以这是一个疯狂的猜测。