---
title: "JPA与Spring2.5整合时发生不能创建entityManagerFactory的问题解决方法"
author: "caoxiping"
date: "2010-06-21T20:05:00Z"
tags: []
categories: ["企业架构"]
slug: "jpa-spring2-5-entitymanagerfactory"
draft: false
lastmod: "2010-06-21T20:05:00Z"
id: 695927
url: "https://caoxiping.iteye.com/blog/695927"
---

今天在做jpa与spring整合时,发现个异常... 如下

异常内容: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource :: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No PersistenceProvider specified in EntityManagerFactory configuration, and chosen PersistenceUnitInfo does not specify a provider class name either

 

解决方法: 在persisitence.xml文件中添加 <provider>org.hibernate.ejb.HibernatePersistence</provider>

 

次要解决方法:在你的spring配置文件中: Container去掉试试,GOOK LUCK!

 

<bean id="entityManagerFactory"
  class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  <property name="persistenceUnitName" value="ssj" />
</bean>