Skip to content

Commit 7286c33

Browse files
committed
Document default behaviour of DataJpaTest#showSql
Closes gh-25843
1 parent e194430 commit 7286c33

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6912,6 +6912,9 @@ TIP: Sometimes writing Spring WebFlux tests is not enough; Spring Boot can help
69126912
You can use the `@DataJpaTest` annotation to test JPA applications.
69136913
By default, it scans for `@Entity` classes and configures Spring Data JPA repositories.
69146914
If an embedded database is available on the classpath, it configures one as well.
6915+
SQL queries are logged by default by setting the `spring.jpa.show-sql` property to `true`.
6916+
This can be disabled using the `showSql()` attribute of the annotation.
6917+
69156918
Regular `@Component` and `@ConfigurationProperties` beans are not scanned when the `@DataJpaTest` annotation is used.
69166919
`@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans.
69176920

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
* {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} annotation can be used to
5454
* override these settings.
5555
* <p>
56+
* SQL queries are logged by default by setting the {@code spring.jpa.show-sql} property
57+
* to {@code true}. This can be disabled using the {@link DataJpaTest#showSql() showSql}
58+
* attribute.
59+
* <p>
5660
* If you are looking to load your full application configuration, but use an embedded
5761
* database, you should consider {@link SpringBootTest @SpringBootTest} combined with
5862
* {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this

0 commit comments

Comments
 (0)