EclipseLink JPA - persistence.xml的位置 [英] EclipseLink JPA - location of persistence.xml

查看:248
本文介绍了EclipseLink JPA - persistence.xml的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将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 - persistence.xml的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆