java - Hibernate Eclipse Oxygen:无法加载 AnnotationConfiguration
问题描述
我一直在折腾来解决这个问题,但没有幸运。四处搜索,似乎要回到相同的帖子和谷歌搜索,而我没有解决这个问题。
正如您在下面的屏幕截图中看到的那样,它说“无法加载 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]
无论如何,希望有人可以提供帮助。
解决方案
推荐阅读
- c++ - 在 C++ DirectX Tool Kit 中渲染纹理问题
- kubernetes - 使用 kops 在 gcp 上验证集群时出现 TLS 握手超时错误
- typescript - 使用 React 和 Apollo 客户端防止对列表中的子元素进行多余的重新获取和重新绘制
- java - 无效值用户输入再次要求放入数组
- sharepoint - JMETER 的 SharePoint 应用程序可行性
- rsocket - Spring Webflux vs Rsocket
- php - 禁止 mediawiki 中的警告
- java - 具有继承的静态变量
- http - 配置 X-XSS 保护标头
- angular - 使用反应形式的角度电子邮件验证