【发布时间】:2021-12-01 11:42:43
【问题描述】:
所以,我决定用 Hibernate 和 JavaFX 制作一个项目。 我已经设计了 UI 并在我用 Maven 创建的项目中对其进行了测试,使用名为“javafx-archetype-fxml”的原型,它工作得很好。 现在我正在尝试将 Hibernate 添加到这个项目中来管理持久层。 我在 Maven 中添加了依赖项,“hibernate-core”v.6.0.0 并继续使用“@Entity”类型注释映射模型类,但 VSCode 无法识别它们。也许我需要在 module-info.java 中添加一个模块?
@Entity 注解无法识别。
这是我的 pom.xml 文件:
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.0.Beta1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.26</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>com.ignaciocassi.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
这是我的 module-info.java 文件:
module com.ignaciocassi {
requires javafx.controls;
requires transitive javafx.graphics;
requires javafx.fxml;
requires java.sql;
opens controllers to javafx.fxml;
exports com.ignaciocassi;
}
我是 Maven 和模块化项目的新手,我想学习。任何建议或帮助将不胜感激。
【问题讨论】:
-
所有这些信息都非常有用,尽管我仍然不知道如何根据我想要使用的功能检查我必须添加的模块。在这种情况下,jakarta.persistence 模块添加了 JPA 注释。我在 Hibernate ORM 指南上找不到任何提及。不管怎样,你的帮助真的很有用,谢谢@jewelsea。
-
用答案替换了 cmets。
标签: java hibernate maven javafx