首页 > 解决方案 > javax.persistence.PersistenceContext.synchronization() 中的错误

问题描述

我正在尝试在 Maven 中构建我的 Jhipster Spring 引导应用程序。但是,Maven 不是在调试模式下构建的。否则,它工作正常。

我添加了以下依赖项,没有帮助。

<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0</version>
</dependency>
Description:

An attempt was made to call the method javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType; but it does not exist. Its class, javax.persistence.PersistenceContext, is available from the following locations:

    jar:file:/C:/Users/User/Documents/audio-book-admin/lib/javax.persistence.jar!/javax/persistence/PersistenceContext.class
    jar:file:/C:/Users/User/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.2.Final/hibernate-jpa-2.1-api-1.0.2.Final.jar!/javax/persistence/PersistenceContext.class
    jar:file:/C:/Users/User/.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/javax/persistence/PersistenceContext.class

It was loaded from the following location:

    file:/C:/Users/User/Documents/audio-book-admin/lib/javax.persistence.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.PersistenceContext

那么,如何正确纠正我的应用程序的类路径以解决上述问题?我是Spring Boot的新手!

标签: javamavenspring-bootdebuggingjhipster

解决方案


首先在您的存储库中删除 maven 目录 hibernate,然后进行 maven 全新安装以正确重新导入您的依赖项。

如果它仍然不能解决您的问题,请制作一个maven tree:dependency以检测导致问题的依赖项并将其排除在您的 pom 中


推荐阅读