在 Config 里面把 hibernate. show_SQL 设置为 true 即可。
不建议开启,开启后会降低程序的运行效率。
1、spring boot 之yml
spring:
jpa:
properties:
hibernate:
format_sql: true //格式化sql语句
show_sql: true //控制台是否打印
use_sql_comments: true //指出是什么操作生成了该语句
2、xml
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>