2

我在使用休眠元模型生成器时遇到问题:

java: Error unmarshalling /META-INF/persistence.xml with exception :
   javax.xml.bind.UnmarshalException
   - with linked exception:
  [org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 103; cvc-elt.1: Cannot find the declaration of element 'persistence'.]

这是我的persistence.xml:

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
                 http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/persistence_2_1.xsd">

  <persistence-unit name="wespital" transaction-type="JTA">
    <jta-data-source>jdbc/wespital</jta-data-source>
  </persistence-unit>
</persistence>

当前版本(1.2.Final)似乎不支持 JPA 2.1,而且我在 git 存储库中没有找到该生成器的任何 beta 版本。还有哪些其他选项可以生成元模型类?我使用wildfly作为应用服务器。

4

3 回答 3

1

2013 年 8 月 9 日发布了一个新版本 (1.3.0.Final),应该可以解决您的问题。

于 2013-08-20T13:45:32.800 回答
1

DataNucleus JPA 元模型生成器生成适用于 JPA 2.0/2.1 的类,请参阅DataNucleus 文档

于 2013-08-20T13:47:16.057 回答
0

我使用了 eclipselink 项目中的元模型生成器,它似乎工作正常。

<dependency>
  <groupId>org.eclipse.persistence</groupId>
  <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
  <version>2.5.0</version>
  <scope>provided</scope>
</dependency>
于 2013-07-21T07:11:05.143 回答