1 在配置文件中添加日志配置 src/main/resources/application.properties # 数据库连接配置 spring.datasource.username=root spring.datasource.password=123456 spring.datasource.url=jdbc:mysql://localhost:3306/mybatis_plus?useSSL=fa
首先,需要在项目中添加SLF4J和Logback的依赖。然后,在配置文件中将log-impl属性设置为SLF4J。例如: properties mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl 同时,还需要在项目的资源目录下添加logback.xml配置文件来定义日志的输出格式和级别。 确保日志级别正确: 无论使用哪种日...
Slf4j提供了丰富的日志级别、格式等配置选项,同时也支持MDC等高级功能,可以帮助开发人员快速、灵活地记录和管理日志信息。 相对于直接使用Log4j或者其他日志框架,使用Slf4j的优势在于可以轻松地切换不同日志框架,并且避免引入多个日志框架导致的冲突和兼容性问题。 使用Slf4j作为MybatisPlus的日志框架时,需要在pom.xml中引...
2、创建mybatis核心配置文件(SqlMapConfig.xml) <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <settings> <setting name="mapUnderscoreToCamelCase" value="true"/> ...
首先,在mybatis-config.xml配置文件中设置setting标签中的logImpl属性 <settings> <setting name="logImpl" value="STDOUT_LOGGING"/> </settings> 1. 2. 3. 运行一下,看一下日志输出了哪些具体东西: 可以看到输出了许多信息: Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' ad...
package com.cunyu.employee.service.Impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.cunyu.employee.entity.Employee; import com.cunyu.employee.mapper.EmployeeMapper; import com.cunyu.employee.service.EmployeeService; /** * Created with IntelliJ IDEA. * * @author...
#配置日志mybatis-plus:configuration:log-impl:org.apache.ibatis.logging.stdout.StdOutImpl#仅控制台输出的日志 配置完日志后,后面的学习就需要注意自动生成的SQL,相信你们会喜欢上MybatisPlus CRUD使用 Insert插入 //测试插入@TestpublicvoidtestInsert(){Airair =newAir(); ...
[12-13 17:20:32 DEBUG] [main] cxxxx.xxxx.xxx.selectCount - <== Total: 1 [12-13 17:20:32 DEBUG] [main] cxxxx.xxxx.xxx.selectCount - <== Total: 1 这里顺便提一下mybatisplus开启打印日志的配置方法适用于spring-boot
[12-13 17:20:32 DEBUG] [main] cxxxx.xxxx.xxx.selectCount - <== Total: 1 [12-13 17:20:32 DEBUG] [main] cxxxx.xxxx.xxx.selectCount - <== Total: 1 这里顺便提一下mybatisplus开启打印日志的配置方法适用于spring-boot