EclipseLink JPA - location of persistence.xml

不羁岁月 提交于 2020-02-26 12:38:26

问题


I am using JPA for a java class and having trouble putting the persistence XML file where it should be.

The IDE i am using is Eclipse Helios. Eclipselink jar files are downloaded and added to my JRE System Library and all. I wrote up the persistence.xml with the tag after getting the following error :

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named customers

Provider tag:

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

The program still doesn't run so i am wondering where should I place persistence.xml (i.e src/main/resources, or lib/META-INF... etc )


回答1:


persistence.xml should be put inside an directory called META-INF under the root of the classpath .

Right click your project in eclipse ==> Properties ==> Java Build Path . Suppose you configure one of the build paths to be /src/main/resources , then you should put the persistence.xml at /src/main/resources/META-INF/persistence.xml



来源:https://stackoverflow.com/questions/8276166/eclipselink-jpa-location-of-persistence-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!