我正在运行带有Spring3.2.5的Pet Clinic示例项目。 Hibernate一切都很好,我想尝试EclipseLink。这是我的business-config.xml
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"
p:database="${jpa.database}" p:showSql="${jpa.showSql}"/>
-->
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
<property name="database" value="mydb" />
</bean>
</property>
<!-- gDickens: BOTH Persistence Unit and Packages to Scan are NOT compatible, persistenceUnit will win -->
<property name="persistenceUnitName" value="mydb"/>
<property name="packagesToScan" value="com.mydb"/>
</bean>
<!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"/>
<!--
Post-processor to perform exception translation on @Repository classes (from native
exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy).
-->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
我一直在接受:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring/business-config.xml]: Cannot create inner bean 'org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter#62d24dc7' of type [org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter] while setting bean property 'jpaVendorAdapter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter#62d24dc7' defined in class path resource [spring/business-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/PersistenceProvider
我做错了什么?
答案 0 :(得分:0)
在拉Eclipselink.jar中使用Maven / POM.xml而不是在java构建路径中包含手动修复我的问题。