简体   繁体   English

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

[英]How to specify JPA 2.1 in persistence.xml?

A quick search on the net reveals 3 or 4 variants how folks have been specifying xmlns and xsi:schemaLocation in persistence.xml . 在网上快速搜索显示3或4个变体,人们如何在persistence.xml指定xmlnsxsi:schemaLocation

What would be the 'correct' manner to specify JPA version 2.1? 指定JPA 2.1版的“正确”方式是什么?

I'm using: 我正在使用:

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

According to the official documentation it must be (like yours): 根据官方文件,它必须(和你的一样):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM