需要以下三个配置
1:设置mybatisplus包下的日志级别为DEBUG;
logging:
level:
com:
baomidou:
mybatisplus: DEBUG2:设置项目mapper目录(dao包路径)的日志级别为DEBUG;
logging:
level:
com:
xxx:
xxx
xxx: DEBUG3:设置mybatis-plus的日志输出方式为slf4j。
mybatis-plus:
#mapper-locations: classpath*:/mappings/**/*.xml
configuration:
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl附:关闭打印
在生产环境,不想打印 SQL 日志,可以通过下面的配置关闭。
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl对于 application.properties 文件
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.nologging.NoLoggingImpl
如果希望通过配置控制 SQL 打印效果,可以将 log-impl 的值设置为外部传入的值
mybatis-plus:
configuration:
log-impl: ${mybatis-plus-log-impl}${mybatis-plus-log-impl} 不同的值就能实现。
以上就是springboot下mybatisplus开启打印sql日志怎么配置的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号