如何在persistence.xml中指定JPA 2.1?

60

在互联网上进行快速搜索,可以发现有三到四种变体是人们如何在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">

2
配置文件OCD...欢迎加入俱乐部。 - Priidu Neemre
1个回答

110

根据 官方文档 ,它必须是(像您的那样):

<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>

4
作为补充,要指出显示此配置的确切位置,可以查看相关的XSD文件(从第50行开始):http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd。 - informatik01

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接