Browse Source

Improve error message when no resources exist at a script location

See gh-25620
pull/25731/head
Yuta Saito 5 years ago committed by Andy Wilkinson
parent
commit
42841b895f
  1. 4
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java
  2. 10
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvokerTests.java

4
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -161,7 +161,7 @@ class DataSourceInitializer { @@ -161,7 +161,7 @@ class DataSourceInitializer {
}
else if (validate) {
throw new InvalidConfigurationPropertyValueException(propertyName, resource,
"The specified resource does not exist.");
"Resource '" + location + "' does not exist.");
}
}
}

10
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvokerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -221,8 +221,10 @@ class DataSourceInitializerInvokerTests { @@ -221,8 +221,10 @@ class DataSourceInitializerInvokerTests {
"spring.datasource.schema:classpath:does/not/exist.sql").run((context) -> {
assertThat(context).hasFailed();
assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class);
assertThat(context.getStartupFailure()).hasMessageContaining("does/not/exist.sql");
assertThat(context.getStartupFailure()).hasMessageContaining("[does/not/exist.sql]");
assertThat(context.getStartupFailure()).hasMessageContaining("spring.datasource.schema");
assertThat(context.getStartupFailure())
.hasMessageContaining("Resource 'classpath:does/not/exist.sql' does not exist.");
});
}
@ -233,8 +235,10 @@ class DataSourceInitializerInvokerTests { @@ -233,8 +235,10 @@ class DataSourceInitializerInvokerTests {
"spring.datasource.data:classpath:does/not/exist.sql").run((context) -> {
assertThat(context).hasFailed();
assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class);
assertThat(context.getStartupFailure()).hasMessageContaining("does/not/exist.sql");
assertThat(context.getStartupFailure()).hasMessageContaining("[does/not/exist.sql]");
assertThat(context.getStartupFailure()).hasMessageContaining("spring.datasource.data");
assertThat(context.getStartupFailure())
.hasMessageContaining("Resource 'classpath:does/not/exist.sql' does not exist.");
});
}

Loading…
Cancel
Save