Eclipse does not recognize content of persistence.xml

前端 未结 27 1804
野趣味
野趣味 2021-01-30 20:44

Im getting the following error in eclipse:

The persistence.xml file does not have recognized content.

My persistence.xml file works great in my application but e

27条回答
  •  长情又很酷
    2021-01-30 21:04

    I had src/main/java/META-INF/persistence.xml working fine in Eclipse with embedded Tomcat. Because it was not being copied into the Maven-built WAR, I moved it to src/main/resources/META-INF.

    Now src/main/resources/META-INF/persistence.xml won't validate.

    If rename to xyz_persistence.xml, it validates fine.
    If rename to persistence.xml, it fails to validate.

    When these annoying situations arise, I often find numerous different "solutions" like mine, most of which are not universally applicable.

    So, here's my "solution", which I think it a hack to get around a bug:

    To remove the error "persistence.xml file does not have recognized content" error, disable the JPA Validator:

    • List item Select menu item Project > Properties > Preferences > Validation
    • List item Disable the JPA Validator for both Manual validation and Build validation.

    You might need to clean and rebuild. Your mileage may vary.

提交回复
热议问题