Eclipse 错误:此项目具有 JPA 方面,但无法创建 JPA 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17328762/
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:46:01  来源:igfitidea点击:

Eclipse bug: This project has the JPA facet, but no JPA project could be created

eclipsejpa-2.0

提问by AllieCat

After restarting Eclipse, I get the following error in my project:

重新启动 Eclipse 后,我的项目中出现以下错误:

This project has the JPA facet, but no JPA project could be created. See the error log for more details.

此项目具有 JPA 方面,但无法创建 JPA 项目。有关更多详细信息,请参阅错误日志。

Nothing I've done (clean project, maven update, etc) will get rid of the error. My JPA Content icon remains greyed out.

我所做的任何事情(清理项目、maven 更新等)都不会消除错误。我的 JPA 内容图标保持灰色。

enter image description here

在此处输入图片说明

It looks like this was a resolved bug at Eclipse bugs...but then why am I still getting it? Should I submit a bug report to Eclipse?

看起来这是Eclipse 错误中解决的错误……但是为什么我仍然得到它?我应该向 Eclipse 提交错误报告吗?

回答by Seb

This is a configuration problem of the project. To solve this problem go to the project properties, and in the node "project facets" unchecked JPA and apply the changes. Now you can checked JPA and apply again!

这是项目的配置问题。要解决此问题,请转到项目属性,然后在节点“项目方面”中取消选中 JPA 并应用更改。现在您可以检查 JPA 并再次申请!

回答by kaushikjain

For me all the above didnt worked.

对我来说,以上所有方法都没有奏效。

So I tried Project Properties>Validate. It solved my problem.

所以我尝试了项目属性>验证。它解决了我的问题。

回答by Hanz

To get rid of this error in Eclipse Luna, I just did a right-click on the project and chose the "Validate" menu item.

为了消除 Eclipse Luna 中的这个错误,我只是右键单击该项目并选择“验证”菜单项。

回答by f6rnando

  1. Alt+Enterin the project
  2. Go for Project facets
  3. UncheckJPAand accept
  4. Right click in the project, go for Validate
  5. Alt+Enterin the project
  6. Go for Project facets
  7. CheckJPA` and accept
  1. Alt+Enter在项目中
  2. 去做 Project facets
  3. 取消选中JPA并接受
  4. 在项目中右键单击,转到 Validate
  5. Alt+Enter在项目中
  6. 去做 Project facets
  7. 检查JPA` 并接受

回答by Jalpesh

Although this is an old thread, will try to give info that might just help someone.

虽然这是一个旧线程,但会尝试提供可能对某人有所帮助的信息。

I assume you have imported a project and it is giving this error.

我假设你已经导入了一个项目,它给出了这个错误。

Step 1 : Check under project properties if jpa is configured.

第 1 步:检查项目属性下是否配置了 jpa。

Step 2 : I have used eclipseLink as the user library for jpa. If you are using eclipse as well, try installing the plugin.

第 2 步:我使用 eclipseLink 作为 jpa 的用户库。如果您也使用 eclipse,请尝试安装该插件。

Step 3 : Check the version of jpa under project properties-> project facets... check for any conflicts in version, usually seen for java version and or any supporting libs. You should be able to change the version from facets.

第 3 步:在项目属性-> 项目构面下检查 jpa 的版本...检查版本是否有任何冲突,通常在 java 版本和/或任何支持的库中看到。您应该能够从方面更改版本。

JPA installation and configuration JPA installation and config

JPA 安装和配置JPA 安装和配置

Step 4 : once JPA is configured for the project, clean and check. This should work.

第 4 步:一旦为项目配置了 JPA,清理并检查。这应该有效。

回答by carrizo

I had the same problem and resolved it by installing both apt and jdt connectors for m2e.

我遇到了同样的问题,并通过为 m2e 安装 apt 和 jdt 连接器解决了它。

Go to Window> Preferences> Maven> Discovery> Open Catalog. Look for m2e-aptand m2e-jdt-compiler. Install and then restart eclipse.

转到Window> Preferences> Maven> Discovery> Open Catalog。寻找m2e-aptm2e-jdt-compiler。安装然后重新启动eclipse。

回答by Michael

Looks like the problem is in some cases caused by a missing JPA implementation in the classpath. After I added a Maven (test scope) dependency, the Eclipse error message disappeared:

看起来问题在某些情况下是由类路径中缺少 JPA 实现引起的。添加 Maven(测试范围)依赖项后,Eclipse 错误消息消失了:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.3.1.Final</version>
    <scope>test</scope>
</dependency>

I this special case I had a "war" project that has a "persistence.xml" but no JPA code itself. The JPA stuff is in the referenced libraries (JARs).

在这个特殊情况下,我有一个“War”项目,它有一个“persistence.xml”,但本身没有 JPA 代码。JPA 内容位于引用库 (JAR) 中。

回答by Nahla

Click right button on your project-->properties-->validation-->uncheck JPA Validation.

您的项目上单击右键--> 属性--> 验证--> 取消选中 JPA 验证

That works for me!

这对我行得通!

回答by Rafael Rocha

Like kaushikjain said, validate your project and the error will disappear. This worked like a charm to me.

就像 kaushikjain 所说的那样,验证您的项目,错误就会消失。这对我来说就像一种魅力。

Right click in your project and Validate.

右键单击您的项目并验证。

enter image description here

在此处输入图片说明

回答by Manu

For me, it was enough to clean the project. Trying to disable JPA in the facet window caused an Exception.

对我来说,清理项目就足够了。尝试在构面窗口中禁用 JPA 导致异常。