Как указать JPA 2.1 в файле persistence.xml?

Быстрый поиск в сети показывает 3 или 4 варианта, как люди указывали xmlns а также xsi:schemaLocation в persistence.xml,

Как правильно указать 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">

1 ответ

Решение

По официальной документации это должно быть (как у вас):

<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>
Другие вопросы по тегам