【问题标题】:How to specify JPA 2.1 in persistence.xml?如何在 persistence.xml 中指定 JPA 2.1?
【发布时间】:2014-02-04 04:51:05
【问题描述】:

在网上快速搜索一下,可以发现人们在persistence.xml 中指定xmlnsxsi:schemaLocation 的三个或四个变体。

指定 JPA 版本 2.1 的“正确”方式是什么?

我正在使用

<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://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

【问题讨论】:

  • 配置文件强迫症...欢迎加入俱乐部。

标签: java jpa jpa-2.1 persistence.xml


【解决方案1】:

根据official documentation,它必须是(像你的一样):

<persistence 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://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
             version="2.1">
    ...
</persistence>

【讨论】:

猜你喜欢
  • 2016-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-16
  • 2011-07-12
  • 2012-05-01
相关资源
最近更新 更多