在运行MyBatis-Plus Generator生成代码时,可能会遇到以下错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
	...省略部分堆栈信息...
Exception in thread "main" java.lang.NullPointerException
	...省略部分堆栈信息...

Process finished with exit code 1

这个错误提示是缺少MySQL驱动,需要在项目中添加MySQL驱动的依赖。可以在Maven或Gradle的配置文件中添加如下依赖:

Maven:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.26</version>
</dependency>

Gradle:

implementation 'mysql:mysql-connector-java:8.0.26'

添加完成后重新运行程序即可。

解决MyBatis-Plus Generator 运行时错误:ClassNotFoundException: com.mysql.jdbc.Driver

原文地址: https://www.cveoy.top/t/topic/oUkf 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录