EclipseLink JPA

编程入门 行业动态 更新时间:2024-10-23 13:27:36
本文介绍了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

本文发布于:2023-10-25 14:08:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1527184.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:EclipseLink   JPA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!