我正在将JPA用于java类,并且无法将持久性XML文件放在应有的位置。
I am using JPA for a java class and having trouble putting the persistence XML file where it should be.
我使用的IDE是Eclipse Helios。 Eclipselink jar文件被下载并添加到我的JRE系统库和所有文件。在收到以下错误后,我用标签写了persistence.xml:
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>org.eclipse.persistence.jpa.PersistenceProvider</provider>程序仍然没有运行所以我想知道我应该在哪里放置persistence.xml(即src / main / resources,或lib / META-INF ... etc)
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 )
推荐答案persistence.xml 应该放在类路径根目录下名为 META-INF 的目录中。
persistence.xml should be put inside an directory called META-INF under the root of the classpath .
在eclipse中右键单击您的项目==>属性==> Java构建路径。假设您将其中一个构建路径配置为 / src / main / resources ,那么您应该将 persistence.xml at /src/main/resources/META-INF/persistence.xml
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
更多推荐
EclipseLink JPA
发布评论