Eclipse - 如何修复错误“在项目中找不到persistence.xml 文件”JPA 问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17695458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:48:11  来源:igfitidea点击:

Eclipse - How to fix error "No persistence.xml file found in project" JPA issue

eclipsegoogle-app-enginemavengwtpersistence.xml

提问by eddyparkinson

Error "No persistence.xml file found in project" in Eclipse.

Eclipse 中的错误“在项目中未找到 persistence.xml 文件”。

Aim: Create a new project GWT+App engine+Maven

目的:新建项目GWT+App引擎+Maven

Steps to create this:

创建这个的步骤:

  1. Google eclipse plugin: select "New Web Application Project".
  2. set the name etc.
  3. right-click on the project > Configure > Convert to Maven...
  4. Fix jdoconfig.xml file: xsi has the wrong value. see Validating jdoconfig with incorrect url
  1. Google eclipse 插件:选择“New Web Application Project”。
  2. 设置名称等。
  3. 右键单击项目 > 配置 > 转换为 Maven...
  4. 修复 jdoconfig.xml 文件:xsi 有错误的值。请参阅 使用不正确的 url 验证 jdoconfig

Then I get the above error.

然后我得到上述错误。

The file exists at scr/META-INF/persistence.xml and also war/WEB-INF/classes/META-INF/persistence.xml But is not being found.

该文件存在于 scr/META-INF/persistence.xml 和 war/WEB-INF/classes/META-INF/persistence.xml 但没有被找到。

Notes: I installed plugins m2e, m2e-wtp and google eclipse plugin

注意:我安装了插件 m2e、m2e-wtp 和 google eclipse 插件

回答by Gerard Downes

If you are using eclipse. Try right clicking the Project File -> Build Path -> Configure Build Path

如果您使用的是日食。尝试右键单击项目文件 -> 构建路径 -> 配置构建路径

Step 1: Add the folder META-INF to the build path

步骤 1:将文件夹 META-INF 添加到构建路径

Step 2: Right click the Project File -> Maven -> Update Project

第二步:右键Project File -> Maven -> Update Project