Java Hibernate无效映射异常

Java Hibernate无效映射异常,java,hibernate,hibernate-annotations,Java,Hibernate,Hibernate Annotations,我的代码与xml映射配合得很好,然后我改为注释,出现以下错误: Exception in thread "main" org.hibernate.InvalidMappingException: Unable to read XML 这是我的XML <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configurati

我的代码与xml映射配合得很好,然后我改为注释,出现以下错误:

Exception in thread "main" org.hibernate.InvalidMappingException: Unable to read XML
这是我的XML

<?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="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost/hibernate1?useLegacyDatetimeCode=false&amp;serverTimezone=UTC</property>
        <property name="connection.username">hibernate1</property>
        <property name="connection.password">mypassword</property>
        <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
        <property name="hibernate.show_sql">true</property>
        <mapping class="hibernate.Profesor" file="" jar="" package="" resource=""/>
        <mapping class="hibernate.Direccion" file="" jar="" package="" resource=""/>
    </session-factory>
</hibernate-configuration>

com.mysql.jdbc.Driver
jdbc:mysql://localhost/hibernate1?useLegacyDatetimeCode=false&服务器时区=UTC
冬眠1
我的密码
org.hibernate.dialogue.mysql5dialogue
真的

我能够让它为我工作,只需更改
连接.url
连接.username
,和
连接.密码

// A SessionFactory is set up once for an application
SessionFactory sessionFactory = new Configuration()
    .configure() // configures settings from hibernate.cfg.xml
    .buildSessionFactory();
删除映射配置文件。也就是说,删除
Profesor.hbm.xml
Direccion.hbm.xml
(如果它们仍然存在)。如果使用注释,则不需要它们。 如果您使用的是Maven,请确保您具有以下依赖项:

另外,
com.mysql.jdbc.Driver
也不推荐使用。使用
com.mysql.cj.jdbc.Driver

如果发布异常的整个堆栈跟踪,则会更有帮助