如何告诉eclipse忽略:“在项目中找不到persistence.xml文件”

时间:2022-01-01 07:20:14

For my projects Necessity i regroup all the persistence.xml entries in one core project which i bind as maven dependency wherever i need.

对于我的项目必要性我重新组合一个核心项目中的所有persistence.xml条目,我将其绑定为maven依赖项,无论我需要什么。

The problem is that the eclipse IDE is always complaining about

问题是eclipse IDE总是在抱怨

No persistence.xml  file found in project

Is there away to keep eclipse quiet about this? Thanks

有没有让这个日子保持沉默?谢谢

6 个解决方案

#1


55  

Thanks to sionnach733 who put me on the right way

如何告诉eclipse忽略:“在项目中找不到persistence.xml文件”

感谢sionnach733让我走上了正确的道路

#2


14  

Window->Preferences->Java Persistence-> JPA-> Errors/warnings-> Project

Then change it from error to whatever you like(warning/info/ignore). You could also choose configure project specific settings if you don't want it to affect other projects

然后将其从错误更改为您喜欢的任何内容(警告/信息/忽略)。如果您不希望它影响其他项目,也可以选择配置项目特定设置

#3


5  

I got rid of this by disabling the JPA facet for my Java project.

我通过禁用Java项目的JPA方面摆脱了这个问题。

#4


5  

If this error occurs on a Maven project that does not require the JPA facet, you can tell m2e not to apply the JPA activation (essentially, not to add the JPA facet during project configuration) by setting the following property in the pom.xml of the affected project:

如果在不需要JPA方面的Maven项目上发生此错误,则可以通过在pom.xml中设置以下属性来告诉m2e不要应用JPA激活(实质上,不是在项目配置期间添加JPA方面)。受影响的项目:

<properties>
    <m2e.jpa.activation>false</m2e.jpa.activation>
</properties>

If you press CTRL-SPACE within an existing <properties> tag, in the pom.xml source, content-assist will provide a shortcut to create the property, so you don't really have to remember the syntax, just that the content assist is there... ;)

如果在现有 标记内按CTRL-SPACE,则在pom.xml源代码中,content-assist将提供创建属性的快捷方式,因此您不必记住语法,只需要内容辅助在那儿... ;)

After applying the property make sure to run Maven -> Update Project (Alt-F5) on the project in question.

应用该属性后,请确保在相关项目上运行Maven - > Update Project(Alt-F5)。

IMHO the accepted answer is no good advice, as it is wrong to just set the error severity to "Ignore", since then Eclipse won't warn on projects that are indeed JPA projects and thus have/need the JPA facet and consequentially should provide a persistence.xml in the expected location (naming and location can be important for artifacts deployed in Java EE environments).

恕我直言,接受的答案是没有好的建议,因为将错误严重性设置为“忽略”是错误的,因为Eclipse不会警告那些确实是JPA项目的项目,因此需要/需要JPA方面,因此应该提供预期位置中的persistence.xml(命名和位置对于Java EE环境中部署的工件很重要)。

In addition by actually configuring a non-JPA project correctly (i. e. without the superfluous JPA facet), Eclipse won't waste time running JPA validation and JPA change monitoring on the project. You might have noticed JPA Project Change Event Handler (waiting) in the Progress view a lot (especially when having multiple JPA projects in the workspace). These no longer run for projects that don't require JPA, when the JPA facet is removed.

此外,通过实际正确配置非JPA项目(即没有多余的JPA方面),Eclipse将不会浪费时间在项目上运行JPA验证和JPA更改监视。您可能已经在Progress视图中注意到了JPA Project Change Event Handler(等待)(特别是在工作区中有多个JPA项目时)。当删除JPA方面时,这些不再针对不需要JPA的项目运行。

#5


4  

All of the other answers to this question deal with the issue by fooling Eclipse into not complaining about the error.

这个问题的所有其他答案都是通过愚弄Eclipse而不是抱怨错误来解决这个问题。

The correct solution to the issue is to remove the JPA Facet from your project. You can do that by right-clicking the project in Project Explorer, select Properties from the menu. From there, go to "Project Facets", and ensure the JPA entry is unchecked. Click Apply, then OK. Go to the Project menu and select Clean. This will remove the spurious error.

该问题的正确解决方案是从项目中删除JPA Facet。您可以通过在Project Explorer中右键单击项目,从菜单中选择Properties来实现。从那里,转到“Project Facets”,并确保取消选中JPA条目。单击Apply,然后单击OK。转到“项目”菜单,然后选择“清除”。这将消除虚假错误。

如何告诉eclipse忽略:“在项目中找不到persistence.xml文件”

#6


-1  

I assume it is the JPA perspective that you have configred.

我假设你已经配置了JPA透视图。

I just created an "empty" persistence.xml in src/main/java/META-INF. It would be seen by maven, so never gets further...It's a hack, I know, but it works...

我刚刚在src / main / java / META-INF中创建了一个“空”的persistence.xml。它会被maven看到,所以永远不会进一步......这是一个黑客,我知道,但它有效......

#1


55  

Thanks to sionnach733 who put me on the right way

如何告诉eclipse忽略:“在项目中找不到persistence.xml文件”

感谢sionnach733让我走上了正确的道路

#2


14  

Window->Preferences->Java Persistence-> JPA-> Errors/warnings-> Project

Then change it from error to whatever you like(warning/info/ignore). You could also choose configure project specific settings if you don't want it to affect other projects

然后将其从错误更改为您喜欢的任何内容(警告/信息/忽略)。如果您不希望它影响其他项目,也可以选择配置项目特定设置

#3


5  

I got rid of this by disabling the JPA facet for my Java project.

我通过禁用Java项目的JPA方面摆脱了这个问题。

#4


5  

If this error occurs on a Maven project that does not require the JPA facet, you can tell m2e not to apply the JPA activation (essentially, not to add the JPA facet during project configuration) by setting the following property in the pom.xml of the affected project:

如果在不需要JPA方面的Maven项目上发生此错误,则可以通过在pom.xml中设置以下属性来告诉m2e不要应用JPA激活(实质上,不是在项目配置期间添加JPA方面)。受影响的项目:

<properties>
    <m2e.jpa.activation>false</m2e.jpa.activation>
</properties>

If you press CTRL-SPACE within an existing <properties> tag, in the pom.xml source, content-assist will provide a shortcut to create the property, so you don't really have to remember the syntax, just that the content assist is there... ;)

如果在现有 标记内按CTRL-SPACE,则在pom.xml源代码中,content-assist将提供创建属性的快捷方式,因此您不必记住语法,只需要内容辅助在那儿... ;)

After applying the property make sure to run Maven -> Update Project (Alt-F5) on the project in question.

应用该属性后,请确保在相关项目上运行Maven - > Update Project(Alt-F5)。

IMHO the accepted answer is no good advice, as it is wrong to just set the error severity to "Ignore", since then Eclipse won't warn on projects that are indeed JPA projects and thus have/need the JPA facet and consequentially should provide a persistence.xml in the expected location (naming and location can be important for artifacts deployed in Java EE environments).

恕我直言,接受的答案是没有好的建议,因为将错误严重性设置为“忽略”是错误的,因为Eclipse不会警告那些确实是JPA项目的项目,因此需要/需要JPA方面,因此应该提供预期位置中的persistence.xml(命名和位置对于Java EE环境中部署的工件很重要)。

In addition by actually configuring a non-JPA project correctly (i. e. without the superfluous JPA facet), Eclipse won't waste time running JPA validation and JPA change monitoring on the project. You might have noticed JPA Project Change Event Handler (waiting) in the Progress view a lot (especially when having multiple JPA projects in the workspace). These no longer run for projects that don't require JPA, when the JPA facet is removed.

此外,通过实际正确配置非JPA项目(即没有多余的JPA方面),Eclipse将不会浪费时间在项目上运行JPA验证和JPA更改监视。您可能已经在Progress视图中注意到了JPA Project Change Event Handler(等待)(特别是在工作区中有多个JPA项目时)。当删除JPA方面时,这些不再针对不需要JPA的项目运行。

#5


4  

All of the other answers to this question deal with the issue by fooling Eclipse into not complaining about the error.

这个问题的所有其他答案都是通过愚弄Eclipse而不是抱怨错误来解决这个问题。

The correct solution to the issue is to remove the JPA Facet from your project. You can do that by right-clicking the project in Project Explorer, select Properties from the menu. From there, go to "Project Facets", and ensure the JPA entry is unchecked. Click Apply, then OK. Go to the Project menu and select Clean. This will remove the spurious error.

该问题的正确解决方案是从项目中删除JPA Facet。您可以通过在Project Explorer中右键单击项目,从菜单中选择Properties来实现。从那里,转到“Project Facets”,并确保取消选中JPA条目。单击Apply,然后单击OK。转到“项目”菜单,然后选择“清除”。这将消除虚假错误。

如何告诉eclipse忽略:“在项目中找不到persistence.xml文件”

#6


-1  

I assume it is the JPA perspective that you have configred.

我假设你已经配置了JPA透视图。

I just created an "empty" persistence.xml in src/main/java/META-INF. It would be seen by maven, so never gets further...It's a hack, I know, but it works...

我刚刚在src / main / java / META-INF中创建了一个“空”的persistence.xml。它会被maven看到,所以永远不会进一步......这是一个黑客,我知道,但它有效......