Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Hibernate JPA和Mysql的Persistence.xml文件_Java_Xml_Hibernate_Jpa_Persistence - Fatal编程技术网

Java Hibernate JPA和Mysql的Persistence.xml文件

Java Hibernate JPA和Mysql的Persistence.xml文件,java,xml,hibernate,jpa,persistence,Java,Xml,Hibernate,Jpa,Persistence,我发现很难找到关于persistence.xml应该是什么样子以及它需要包含什么的最新和清晰的解释。对于以下情况,您的典型persistence.xml文件是什么样子的: 提供者:JPA的Hibernate实现 Mysql数据库 数据库名称:hibernatetest 用户名:root 密码:12345 数据库url:localhost端口3306 为了简单起见,我的需要持久化的实体类位于com.example.MyClass 提前谢谢 下面是一个基本persistence.xml示例: &

我发现很难找到关于persistence.xml应该是什么样子以及它需要包含什么的最新和清晰的解释。对于以下情况,您的典型persistence.xml文件是什么样子的:

  • 提供者:JPA的Hibernate实现
  • Mysql数据库
  • 数据库名称:hibernatetest
  • 用户名:root
  • 密码:12345
  • 数据库url:localhost端口3306
为了简单起见,我的需要持久化的实体类位于com.example.MyClass


提前谢谢

下面是一个基本persistence.xml示例:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
        version="2.0">
    <persistence-unit name="org.hibernate.tutorial.jpa">
        <class>com.example.MyClass</class>
    <class>...</class>
    <class>...</class>
    </persistence-unit>
</persistence>

com.example.MyClass
...
...
您可以在此处找到更多详细信息:

谢谢@Hejwo我实际上已经在他们的文档中阅读了该教程,但是标签之间有什么区别呢?“…”对我上你的课没有多大帮助。我用更好的例子更新了答案。