gpt4 book ai didi

java - 在 Spring 3.2.5 中使用 EclipseLink(Pet Clinic 项目)

转载 作者:太空宇宙 更新时间:2023-11-04 14:52:21 24 4
gpt4 key购买 nike

我正在运行 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

我做错了什么?

最佳答案

在拉取 Eclipselink.jar 中使用 Maven/POM.xml,而不是手动包含在 java 构建路径中,解决了我的问题。

关于java - 在 Spring 3.2.5 中使用 EclipseLink(Pet Clinic 项目),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23643066/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com