SpringBoot 项目,三种方式实现打印 sql 日志

方式一:指定mybatis日志级别

复制代码
# application.yml
mybatis:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
# 等价于application.properties
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

方式二、Mybatis-Plus配置(如果用了 Mybatis-Plus )

复制代码
# 开启mybatis-plus自带SQL打印
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

方式三、mybatis-config.xml 配置(一般是在配置文件中指定了读取 mybatis-config 才这样写)

xml 复制代码
 <configuration>
    <settings>
        <setting name="logImpl" value="STDOUT_LOGGING"/>
    </settings>
</configuration>
相关推荐
Flittly2 天前
【AgentScope Java新手村系列】(16)从RAG到多路检索
java·spring boot·spring
人活一口气2 天前
从JVM调优到MCP协议:Java全栈技术体系深度总结与企业级架构实践
java·spring boot
Java陈序员3 天前
企业级!一个基于 Java 开发的开源 AI 应用开发平台!
spring boot·agent·mcp
杨运交3 天前
[041][公共模块]分布式唯一ID生成器设计与实现:一款灵活可扩展的雪花算法框架
spring boot
Flittly4 天前
【AgentScope Java新手村系列】(14)人机交互
java·spring boot·spring
Flynt5 天前
从Spring Boot 4.0升到4.1,我在Maven和gRPC上栽了跟头
java·spring boot·后端
唐青枫5 天前
MySQL JSON 实战详解:从存储、查询、更新到 JSON_TABLE 与索引
sql·mysql
掉鱼的猫6 天前
Spring Boot → Solon 注解迁移实战指南:一张对照表说清楚
java·spring boot
人活一口气7 天前
Spring Boot与AIGC的完美结合:从零搭建智能内容生成平台
java·spring boot·aigc
掉头发的王富贵7 天前
【StarRocks】极限十分钟入门StarRocks
数据库·sql·mysql