diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 58be6140cd..6400155c36 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1526,6 +1526,13 @@ For example, typical POM dependencies would be: ---- +TIP: If, for whatever reason, you do configure the connection URL for an embedded +database, care should be taken to ensure that the database’s automatic shutdown is +disabled. If you're using H2 you should use `DB_CLOSE_ON_EXIT=FALSE` to do so. If you're +using HSQLDB, you should ensure that `shutdown=true` is not used. Disabling the database's +automatic shutdown allows Spring Boot to control when the database is closed, thereby +ensuring that it happens once access to the database is no longer needed. + NOTE: You need a dependency on `spring-jdbc` for an embedded database to be auto-configured. In this example it's pulled in transitively via `spring-boot-starter-data-jpa`. diff --git a/spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java b/spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java index 024d5dabce..c9b1d142c6 100644 --- a/spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java +++ b/spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java @@ -82,7 +82,6 @@ public class SpringApplicationContextLoader extends AbstractContextLoader { throws Exception { assertValidAnnotations(config.getTestClass()); SpringApplication application = getSpringApplication(); - application.setRegisterShutdownHook(false); application.setMainApplicationClass(config.getTestClass()); application.setSources(getSources(config)); ConfigurableEnvironment environment = new StandardEnvironment();