Hibernate SpringBoot:无法在资源Hibernate.cfg.xml中的第0行和第0列执行解组。消息:空

Hibernate SpringBoot:无法在资源Hibernate.cfg.xml中的第0行和第0列执行解组。消息:空,hibernate,spring-boot,Hibernate,Spring Boot,我正在学习SpringBoot和Hibernate,我试图用em制作一些应用程序,但我遇到了那个错误 我已导入Hibernate版本5.4.5.Final 以及MySQL版本8.0.17 我使用*Maven项目 控制台日志: Exception in thread "main" org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 0 an

我正在学习SpringBoot和Hibernate,我试图用em制作一些应用程序,但我遇到了那个错误

我已导入Hibernate版本5.4.5.Final 以及MySQL版本8.0.17

我使用*Maven项目

控制台日志:

Exception in thread "main" org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 0 and column 0 in RESOURCE hibernate.cfg.xml. Message: null
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:133)
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65)
    at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57)
    at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:165)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:258)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:244)
    at com.ahmed.demo.DemoApplication.main(DemoApplication.java:21)
Caused by: javax.xml.bind.UnmarshalException
 - with linked exception:
[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[8,131]
Message: The reference to entity "useJDBCCompliantTimezoneShift" must end with the ';' delimiter.]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:485)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:463)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:435)
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:126)
    ... 6 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[8,131]
Message: The reference to entity "useJDBCCompliantTimezoneShift" must end with the ';' delimiter.
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:652)
    at java.xml/com.sun.xml.internal.stream.XMLEventReaderImpl.peek(XMLEventReaderImpl.java:277)
    at java.xml/javax.xml.stream.util.EventReaderDelegate.peek(EventReaderDelegate.java:98)
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor$NamespaceAddingEventReader.peek(JaxbCfgProcessor.java:254)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.handleCharacters(StAXEventConnector.java:179)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.bridge(StAXEventConnector.java:141)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:460)
    ... 8 more

休眠配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/notedb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    </session-factory>
</hibernate-configuration>


我创建了数据库,但没有创建表,我让hibernate来做。

hibernate配置文件中不需要密码吗?
你试过了吗?

我的MySql版本有问题,所以我重新安装了所有版本并开始了一个新项目,现在它工作得很好,谢谢!
package com.ahmed.demo;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.hibernate.*;
import org.hibernate.cfg.Configuration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.ahmed.demo.model.Account;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {

        Account account = new Account();
        account.setaUsername("ahmed");
        account.setaPassword("ahmedpassword");

        SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
        Session session = sessionFactory.getCurrentSession();
        session.beginTransaction();
        session.save(account);
        session.getTransaction().commit();
    }

}