java - 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的新手!
解决方案
首先在您的存储库中删除 maven 目录 hibernate,然后进行 maven 全新安装以正确重新导入您的依赖项。
如果它仍然不能解决您的问题,请制作一个maven tree:dependency以检测导致问题的依赖项并将其排除在您的 pom 中
推荐阅读
- sapui5 - SAPUI5 在运行时将 operationMode 更改为 client
- jquery - 如何获取特定类的下一个所有元素?
- javascript - 如何将 src 文件中的 js 文件导入 index.html?
- php - Yii2 中的本地组件是什么?
- spring - 没有 Spring Boot 和 @EnableAutoConfiguration 的 Spring Boot 2 执行器
- podio - Podio 和 Zoho 人员之间的 Webhook 集成
- opencv - 与 opencv cv::resize 一起使用的巨大 virt 内存
- neo4j - 在 websphere 应用服务器中为 neo4j 创建数据源时出错
- angular - http-server -p 8082 显示 ERR_INVALID_REDIRECT
- xamarin.forms - xamarin shell:动态生成路由页面