问题描述
我在eclipse中收到以下错误:
Im getting the following error in eclipse:
persistence.xml文件没有可识别的内容。
The persistence.xml file does not have recognized content.
我的persistence.xml文件在我的应用程序中运行良好,但eclipse不断给我这个错误。移动文件并使用m2eclipse更新我的项目配置后,我得到了这个。我没有更改文件本身。有人知道如何解决这个问题吗?
My persistence.xml file works great in my application but eclipse keeps giving me this error. I got this after moving the file and updating my project configuration with m2eclipse. I did not change the file itself. Anyone knows how to solve this?
persistence.xml:
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="localDB" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>package.Users</class>
<properties>
<!-- enable warnings for debugging -->
<property name="openjpa.Log" value="DefaultLevel=TRACE, Runtime=INFO, Tool=INFO, SQL=TRACE"/>
<!-- connection properties -->
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost/test"/>
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
<property name="openjpa.ConnectionUserName" value="root"/>
<property name="openjpa.ConnectionPassword" value=""/>
</properties>
</persistence-unit>
</persistence>
更新
看起来m2eclipse中的一个错误与jpa结合使用。
Looks like a bug in m2eclipse in combination with jpa.
暂时解决设置选项将其显示为警告而不是错误
Temporarily solved by setting the option to show it as a warning instead of an error
推荐答案
我通过以下方式解决了问题(我正在使用RAD v8.5.1):
I fixed the problem the following way (I'm using RAD v8.5.1):
- Windows - >首选项 - >验证
- 向下滚动到JPA Validator并点击设置下的省略号。
- 点击添加包含组...按钮。
- 点击新的Include Group似乎突出了它。
- 点击添加规则...按钮。
- 弹出一个对话框菜单。单击文件夹或文件名单选按钮,然后单击下一步。
- 单击浏览文件夹...并导航到您的src目录(在我的情况下,它是您工作区内的项目(我的项目是多模块应用程序中的.war)中的src / main / resources)。
- 点击完成。
- 点击确定。这将提示完整版本。
- 错误将消失。
- Windows --> Preferences --> Validation
- Scroll down to "JPA Validator" and click on the Ellipses under Settings.
- Click on the "Add Include Group..." button.
- Click on the new Include Group that appeared to highlight it.
- Click on the "Add Rule..." button.
- A dialog menu pops up. Click the "Folder or file name" radio button and click on "Next".
- Click on "Browse Folder..." and navigate to your src directory (in my case, it was "src/main/resources") within your project (my project was a .war in a multi module app) in your workspace.
- Click on "Finish".
- Click on "OK". This will prompt a full build.
- The error will go away.
这篇关于Eclipse无法识别persistence.xml的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!