JPA Spring Hibernate 整合报错,百思不得其解,求指教~
2013-09-16 20:02:11,034 ERROR org.springframework.web.servlet.DispatcherServlet:(FrameworkServlet.java:315)
- Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cardAction': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cardService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cardDAO': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [springmvc-servlet.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: EnterpriseCard2] Unable to build EntityManagerFactory 展开
<bean id="entityManagerFactory"
你的Spring的配置文件中是不是有下面这段配置呢?
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!-- 此种方式不推荐,对jpa的侵入性太强,除非数据库连接池也在spring中配置
<property name="dataSource"
ref="dataSource" /> -->
<property name="persistenceUnitName" value="Jweb" />
</bean>
<!-- 自动装载EntityManager -->
<context:annotation-config />
<!-- 配置事务管理器 -->
<bean id="entityManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
如果有的话,看下jar包是否缺少了。看下这个4个是不是有的
spring-orm-3.0.5.RELEASE.jar
spring-jdbc-3.0.5.RELEASE.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate-entitymanager-3.6.0.Final.jar
创建这个bean 错了
这个是JPA的bean 规定的 我是弄了很久 突然间不行的 之前正常运行
后面是不是还有错误信息:比如: Caused by:
感觉好像是你的配置文件配错了吧,在初始化的时候就报错了。
没贴完!
贴出来看看呀童鞋。