Eclipse无法识别persistence.xml的内容

编程入门 行业动态 更新时间:2024-10-22 05:08:02
本文介绍了Eclipse无法识别persistence.xml的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在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="java.sun/xml/ns/persistence" xmlns:xsi="www.w3/2001/XMLSchema-instance" xsi:schemaLocation="java.sun/xml/ns/persistence java.sun/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.

bugs.eclipse/bugs/show_bug.cgi?id=251323

暂时解决设置选项将其显示为警告而不是错误

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的内容

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

    发布评论

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

    >www.elefans.com

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