尝试运行测试方法时出现以下错误: java.lang.ClassFormatError:方法中的Absent Code属性,在类文件javax / persistence / PersistenceContextType
中不是本机的或抽象的正如Google所说的依赖问题。我有以下maven依赖项:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>compile</scope>
</dependency>
我已经在maven中添加了jpa的hibernate实现:
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
当我在IntelliJ IDEA中运行测试时,我可以看到类路径:
-classpath "...C:\Users\sav\.m2\repository\javax\javaee-api\6.0\javaee-api-6.0.jar;...C:\Users\sav\.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.0-api\1.0.1.Final\hibernate-jpa-2.0-api-1.0.1.Final.jar;..."
所以两个罐子都存在。
请告诉我,我该怎么做才能解决它?我无法删除对javaee-api的依赖,因为我正在使用@Inject注释。
答案 0 :(得分:0)
我已经将javaee-api的范围从编译改为提供,它解决了问题。
感谢。