EclipseLinke:没有名为META-INF / services / javax.persistence.spi的资源文件:找不到PersistenceProvider

我正在使用EclipseLink,甚至我已经使用maven导入了所有必需的jar文件,我仍然得到了Exception:

线程“main”中的exceptionjavax.persistence.PersistenceException:找不到名为META-INF / services / javax.persistence.spi.PersistenceProvider的资源文件。 请确保持久性提供程序jar文件位于类路径中。

在Maven pom我有依赖:

 javax.persistence persistence-api 1.0.2 provided  

这是我的persistence.xml:

    org.eclipse.persistence.jpa.PersistenceProvider com.testJPABasis.Person   

在日食中的clathpath: 在此处输入图像描述

实际生成exception的类:

 public class TestJPA { public static void main(String[] args) { Person person = new Person(); person.setPersonID(1); EntityManagerFactory emf = Persistence.createEntityManagerFactory("PersistenzJPAProjekt"); EntityManager em = emf.createEntityManager(); } } 

persistence.xml直接位于META-INF下。 据我所知,我不需要Glassfish或Tomcat,因为EclipseLink是为独立应用程序而制作的。 如果我错了,也许这就是原因。 Meta-Inf被放置在:

在此处输入图像描述

persistence-api就是这样的:API(主要是接口)。 您仍然需要包含实际的持久性提供程序; 看起来你想要EclipseLink。