JavaFX首个JDBC项目报错:找不到waffle.jna模块(被org.mariadb.jdbc依赖)
解决Module waffle.jna not found问题
这个错误是因为org.mariadb.jdbc模块依赖waffle.jna模块,但你的项目既没有引入该依赖库,也没在模块配置中声明依赖。按以下步骤解决:
步骤1:添加waffle-jna依赖
如果用Maven管理项目,在pom.xml中加入以下依赖:<dependency> <groupId>com.github.waffle</groupId> <artifactId>waffle-jna</artifactId> <version>3.3.0</version> <!-- 可根据MariaDB驱动版本调整为兼容版本 --> </dependency>若用Gradle,在
build.gradle中添加:implementation 'com.github.waffle:waffle-jna:3.3.0'手动管理依赖的话,下载对应版本的waffle-jna JAR包,放入项目的模块路径或类路径中。
步骤2:更新module-info.java
在你的模块声明中添加对waffle.jna的依赖:module com.example.obs { requires javafx.controls; requires javafx.fxml; requires org.controlsfx.controls; requires org.kordamp.bootstrapfx.core; requires javafx.graphics; requires java.sql; requires org.mariadb.jdbc; requires waffle.jna; // 新增这一行 opens com.example.obs to javafx.fxml; exports com.example.obs; }可选:确认版本兼容性
若仍有问题,查看MariaDB JDBC驱动的依赖树,确保使用的waffle-jna版本与驱动依赖的版本一致,避免版本冲突。
内容的提问来源于stack exchange,提问作者ismail
相关产品推荐
相关产品推荐

