2016-03-08 40 views
0

春天启动的项目,使用JdbcTemplate,并要显示其执行的SQL,配置如下春天开机可以显示SQL甚至使用的JdbcTemplate直接

spring.jpa.show-sql=true 
spring.jpa.properties.hibernate.format_sql=true 

但没有输出,似乎上面的配置只支持spring data jpa,所以我想知道是否存在某种方式可以显示sql甚至直接使用JdbcTemplate

回答

5

有一个原因为什么该属性命名为spring.jpa东西:它是指示你它以某种形式与JPA相关。

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

logging.level.org.springframework.jdbc.core.JdbcTemplate=debug 
+0

谢谢! '2016-03-11 18:57:00.168 DEBUG 19587 --- [restartedMain] osjdbc.core.JdbcTemplate:执行准备好的SQL语句[select mobile,max(total_amount)total_amount from user_draw_log where total_amount> 0 group by mobile order by max(total_amount)desc limit?,?;] ' – zhuguowei