简体   繁体   English

XML 文档结构必须在同一实体内开始和结束

[英]XML document structures must start and end within the same entity

Getting the error while making a small project of inserting and retrieving data from database using technologies JAVA, JPA, MAVEN, MYSQL.使用 JAVA、JPA、MAVEN、MYSQL 技术制作从数据库插入和检索数据的小项目时出现错误。 Below is my code.下面是我的代码。

This is my persistence.xml code:这是我的 persistence.xml 代码:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
    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">

    <persistence-unit name="JEETut3" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

        <class>com.newthinktank.JEETut3.Customer</class>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/test4"/>
            <property name="javax.persistence.jdbc.user" value="testuser"/>
            <property name="javax.persistence.jdbc.password" value="test"/>
        </properties>

    </persistence-unit>

This is Customer.java:这是 Customer.java:

package com.newthinktank.JEETut3;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name ="customer")
public class Customer implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "custID", unique = true)
    private int id;

    @Column(name = "firstName", nullable = false)
    private String fName;

    @Column(name = "lastName", nullable = false)
    private String lName;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getfName() {
        return fName;
    }

    public void setfName(String fName) {
        this.fName = fName;
    }

    public String getlName() {
        return lName;
    }

    public void setlName(String lName) {
        this.lName = lName;
    }


}

I included different jars: hibernate-validation, java-persistence, hibernate-jpa and hibernate-entityManager in the build path and also class path of project itself.我在构建路径和项目本身的类路径中包含了不同的 jars:hibernate-validation、java-persistence、hibernate-jpa 和 hibernate-entityManager。 I also copied persistence.xml in resource folder.我还在资源文件夹中复制了persistence.xml。 I did lots of things, but it does not work, getting always the same error.我做了很多事情,但它不起作用,总是出现相同的错误。

Problem has nothing to do with jars or persistence.xml location.问题与 jars 或persistence.xml位置无关。

File persistence.xml is invalid, because <persistence ...> is not closed.文件persistence.xml无效,因为<persistence ...>未关闭。 Problem can be solved by adding </persistence> to the end of the persistence.xml问题可以通过在persistence.xml末尾添加</persistence>解决

暂无
暂无

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

相关问题 SAXException = XML文档结构必须在同一实体内开始和结束 - SAXException=XML document structures must start and end within the same entity SAXParseException XML文档结构必须在同一实体中开始和结束 - SAXParseException XML document structures must start and end within the same entity XML 文档结构必须在同一实体内开始和结束吗? - XML document structures must start and end within the same entity? SAXParseException:XML文档结构必须在同一实体中开始和结束 - SAXParseException: XML document structures must start and end within the same entity SAX:XML文档结构必须在同一实体内开始和结束 - SAX: XML document structures must start and end within the same entity XML错误:“ XML文档结构必须在同一实体内开始和结束。” - XML Error: “XML document structures must start and end within the same entity.” XML文档结构必须在同一实体内开始和结束。 使用xslt将xml转换为html - XML document structures must start and end within the same entity. xml to html using xslt javax.xml.bind.UnmarshalException:XML文档结构必须在同一实体内开始和结束 - javax.xml.bind.UnmarshalException: XML document structures must start and end within the same entity 在 netbeans 中清理和构建 javafx 应用程序时出错,XML 文档结构必须在同一实体中开始和结束 - error while cleaning and building javafx app in netbeans, XML document structures must start and end within the same entity eclipse中的SaxParseException:XML文档结构必须在同一实体内开始和结束 - SaxParseException in eclipse: XML document structures must start and end within the same entity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM