Spring Boot 打印SQL日志
时间: 2023-07-09 20:23:28 浏览: 140
在 Spring Boot 中,可以通过配置来开启 SQL 日志打印。具体的步骤如下:
- 在 application.properties 或 application.yml 文件中添加以下配置:
spring.datasource.url=jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
- 重新启动应用程序,此时就可以在控制台中看到 SQL 日志的输出了。
需要注意的是,如果应用程序中使用了多个数据源,则需要在配置文件中为每个数据源分别设置上述配置。
相关问题
springboot mybatis打印sql日志
你可以在Spring Boot中使用MyBatis打印SQL日志,只需要在application.properties文件中添加以下配置:
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
这将启用MyBatis的标准输出日志实现,它将在控制台上打印SQL语句和参数。
相关推荐

















