Hibernate messages when using @DataJpaTest with SpringBoot

时间:2017-08-04 12:00:17

标签: java hibernate spring-boot

I am doing @DataJpaTest on default spring boot settings. When I run the test, hibernate(?) is flooding console with schema creation messages like:

Hibernate: alter table ...
Hibernate: alter table ...
Hibernate: alter table ...
Hibernate: alter table ... 
Hibernate: call next value ...

And so on. Does anyone knows how to disable this messages? I have logback configuration for test with log level OFF on root logger.

/Annonymous

1 个答案:

答案 0 :(得分:4)

@DataJpaTest默认显示SQL输出。

 * If SQL output should be logged.
 * @return if SQL is logged
 */
@PropertyMapping("spring.jpa.show-sql")
boolean showSql() default true;

您可以在注释@DataJpaTest(showSql=false)

中设置showSql = false