如何在persistence.xml中指定JPA 2.1? [英] How to specify JPA 2.1 in persistence.xml?

查看:90
本文介绍了如何在persistence.xml中指定JPA 2.1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网上快速搜索显示3或4个变体人们如何指定 xmlns xsi:schemaLocation 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.

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

What would be the 'correct' manner to specify JPA version 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">


推荐答案

根据官方文档必须(和你的一样):

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>

这篇关于如何在persistence.xml中指定JPA 2.1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆