This setting is rather hidden, hard to find, and can set you up. I wanted to disable SQL query logging, but somehow the queries continued to show in the console. Later I found out that the Annotation enabled the setting spring.jpa.show-sql which I had disabled. Now all my tests use @DataJpaTest(showSql = false) to avoid flooding the logs. But I would prefer if the Annotation did not set it to true in the first place.

Comment From: wilkinsona

Thanks for the suggestion. Unfortunately, I think this is a situation where we won't be able to please all of the people all of the time. SQL logging has been enabled since @DataJpaTest's introduction in Spring Boot 1.4. From what we've seen in the five years since then, the functionality has been well received and has proven to be useful. As far as I can recall, this is the first issue requesting a change to the default so I don't think we can justify doing so at this time.

I'd like to understand why you consider the setting to be hidden. The javadoc for showSql attribute describes the behaviour and notes that it defaults to true. What could we do to make the default behaviour more obvious? It isn't mentioned in the class-level javadoc so I think it may be worth adding something there.

I also think we could look at making it easier to override the default across all your tests. As things stand, the annotation's attribute is mapped onto a spring.jpa.show-sql entry in a property source that's added in first place after, for example, @TestPropertySource's property source has been added. This means that you can't override it with @TestPropertySource.

Comment From: gregorriegler

I would have never expected this annotation to override show-sql. I expected it to configure the datasource, repositories and so on - yes. but it would be the last place to search for the reason my queries are logged. I'm searching my configs and my code for that stuff. show-sql false is the default, so I assume that I must have changed it somewhere. "The Framework would never override such a default", is what I'm thinking. Show-sql is very situational, so it's good to default to false.

It is a thing you have to know, and if you don't, well - good luck finding it. I recommend asking more people that are not biased, like us both. People who never used it perhaps. People who care about their stdout.

Comment From: wilkinsona

We haven't asked anyone, biased or otherwise, for their opinion about the current behaviour. The impression that we have is from people's tweets, discussion on Gitter, etc. If anything, we're more likely to notice and remember the negative comments over the positive ones.

In short, we haven't seen feedback from a broad enough number of people to warrant changing the default so we're going to have to agree to disagree here. Thanks again for the suggestion.

I've opened https://github.com/spring-projects/spring-boot/issues/25843 to document things more prominently.