spring boot可以显示sql甚至直接使用JdbcTemplate

zhu*_*wei 4 jdbctemplate spring-boot

spring boot项目,用过JdbcTemplate,想要显示执行的sql,配置如下

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
Run Code Online (Sandbox Code Playgroud)

但没什么输出,看来上面的配置只支持spring data jpa,所以我想知道确实存在某种方式可以显示sql甚至JdbcTemplate直接使用?

Ste*_*oll 14

这个属性被命名的原因有一个spring.jpa:它是以某种形式表明它与JPA有关.

如果您正在使用JdbcTemplate,那么您不使用JPA,因此该属性不会产生任何影响.您可以为org.springframework.jdbc.core.JdbcTemplate该类启用日志记录

logging.level.org.springframework.jdbc.core.JdbcTemplate=debug
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

6057 次

最近记录:

9 年,8 月 前