在Cloud Foundry上部署Spring Boot微服务时,我面临以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/ge/pd/reports/config/HibernateConfig.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
当我检查了堆栈溢出的许多解决方案以及许多其他门户网站的解决方案时,所有解决方案都与jar版本冲突有关。
我从应用程序中删除了所有冲突jar,并使用所需的所有jar版本进行了更新。
I am using below jar and its version:
hibernate-core-5.0.12.Final.jar - 5.0.12
hibernate-jpa-2.1-api-1.0.0.Final.jar - 2.1
hibernate-entitymanager-5.0.12.Final.jar - 5.0.12
openjpa-2.4.0.jar - 2.4.0
请提供解决方案。
答案 0 :(得分:1)
这确实看起来像是一个依赖冲突,更具体地说,是Hibernate 5.0.12(which uses JPA 2.1)和OpenJPA 2.4.0(which uses JPA 2.0)之间的依赖冲突。尝试删除OpenJPA依赖项。
如this SO线程所示,该方法是在JPA 2.1中引入的。