我一直在辗转反侧解决这个问题,但一直不幸运。搜索过,似乎回到相同的帖子和谷歌搜索,我不会去解决这个问题。
正如您可以看到下面的屏幕截图,它的说法"无法加载AnnotationConfiguration"同时我不知道为什么。当我在"配置文件"下添加我的hibernate.cfg.xml时,会出现错误。 DTD与它有关吗?我已经在pom.xml中添加了注释。我想做一个逆向工程来从数据库中生成模型类。
这是我的pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.cabrera.ebookr</groupId>
<artifactId>ebookr</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts-core -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts-core</artifactId>
<version>1.3.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts-taglib -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts-taglib</artifactId>
<version>1.3.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.0.CR2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-annotations -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
</dependencies>
</project>
我的hibernate.cfg.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-reverse-engineering-3.0.dtd"> -->
<!DOCTYPE hibernate-reverse-engineering PUBLIC
"-//Hibernate/Hibernate Reverse Engineering 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.password">test</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ebookr</property>
<property name="hibernate.connection.username">webuser</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>
我不知道这是否也有帮助,也许还有其他帖子,但只是为了给出一些细节,我也无法通过eclipse创建hibernate.cfg.xml,因为发生了一些错误,我想,我只是手动创建它,没有太大区别对吗?错误是:
Unhandled event loop exception .ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
无论如何,希望有人可以提供帮助。