Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter. Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. Registered plugin: 'com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor@7857cb1d' Property 'mapperLocations' was not specified.
时间: 2025-07-19 07:16:21 浏览: 3
### 日志配置问题
在启动 MyBatis 应用程序时,可能会看到类似 `MyBatis logging initialized with StdOutImpl` 的信息。这表明 MyBatis 使用了 `StdOutImpl` 作为日志实现,通常用于简单的控制台输出。为了更详细的日志管理和更友好的调试体验,推荐配置使用如 Log4j2 或 SLF4J 等成熟的日志框架。可以通过在 `mybatis-config.xml` 文件中配置日志实现类来改变默认的日志行为。
### 数据库驱动类弃用警告
当使用较新版本的 MySQL 数据库时,可能会遇到 `com.mysql.jdbc.Driver` 被标记为弃用的警告。这是因为 MySQL 官方推荐使用新的驱动类 `com.mysql.cj.jdbc.Driver`。旧的驱动类虽然仍可工作,但可能在未来版本中被移除。更新驱动类需要修改数据库连接配置中的驱动类名,并确保使用的 JDBC URL 符合新驱动的要求,例如使用 `jdbc:mysql://` 而不是旧的格式。
### MyBatis-Plus 插件注册
MyBatis-Plus 提供了丰富的插件功能,可以用来增强 MyBatis 的核心功能。插件的注册通常在配置类中完成,通过向 `MyBatisPlusInterceptor` 添加特定的插件并将其添加到 MyBatis 的配置中。例如,分页插件可以通过以下方式注册:
```java
@Configuration
public class MyBatisPlusConfig {
@Bean
public MyBatisPlusInterceptor myBatisPlusInterceptor() {
MyBatisPlusInterceptor interceptor = new MyBatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
}
```
### Mapper 文件位置未指定
如果启动应用时出现 `mapperLocations` 未指定的警告,这意味着 MyBatis 无法找到 mapper 文件的位置。解决这个问题的方法是在 `mybatis-config.xml` 或者 Spring Boot 的 application.properties 文件中正确设置 `mapperLocations` 属性。例如,在 `mybatis-config.xml` 中:
```xml
<configuration>
<mappers>
<mapper resource="mappers/UserMapper.xml"/>
</mappers>
</configuration>
```
或者在 Spring Boot 的配置文件中:
```properties
mybatis.mapper-locations=classpath:mappers/*.xml
```
确保路径正确无误,并且 mapper 文件存在于指定的目录下。
阅读全文
相关推荐



















