Merge branch '2.0.x'
This commit is contained in:
@@ -58,12 +58,12 @@ class DataSourceBeanCreationFailureAnalyzer
|
||||
|
||||
private String getDescription(DataSourceBeanCreationException cause) {
|
||||
StringBuilder description = new StringBuilder();
|
||||
description.append("Failed to auto-configure a DataSource: ");
|
||||
if (!this.environment.containsProperty("spring.datasource.url")) {
|
||||
description.append("'spring.datasource.url' is not specified and ");
|
||||
description.append("Failed to configure a DataSource: ");
|
||||
if (!StringUtils.hasText(cause.getProperties().getUrl())) {
|
||||
description.append("'url' attribute is not specified and ");
|
||||
}
|
||||
description.append(
|
||||
String.format("no embedded datasource could be auto-configured.%n"));
|
||||
String.format("no embedded datasource could be configured.%n"));
|
||||
description.append(String.format("%nReason: %s%n", cause.getMessage()));
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB
|
||||
if (!StringUtils.hasText(driverClassName)) {
|
||||
throw new DataSourceBeanCreationException(
|
||||
"Failed to determine a suitable driver class",
|
||||
this.embeddedDatabaseConnection);
|
||||
this, this.embeddedDatabaseConnection);
|
||||
}
|
||||
return driverClassName;
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB
|
||||
if (!StringUtils.hasText(url)) {
|
||||
throw new DataSourceBeanCreationException(
|
||||
"Failed to determine suitable jdbc url",
|
||||
this.embeddedDatabaseConnection);
|
||||
this, this.embeddedDatabaseConnection);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
@@ -513,14 +513,21 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB
|
||||
|
||||
static class DataSourceBeanCreationException extends BeanCreationException {
|
||||
|
||||
private final DataSourceProperties properties;
|
||||
|
||||
private final EmbeddedDatabaseConnection connection;
|
||||
|
||||
DataSourceBeanCreationException(String message,
|
||||
DataSourceBeanCreationException(String message, DataSourceProperties properties,
|
||||
EmbeddedDatabaseConnection connection) {
|
||||
super(message);
|
||||
this.properties = properties;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public DataSourceProperties getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public EmbeddedDatabaseConnection getConnection() {
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ public class DataSourceBeanCreationFailureAnalyzerTests {
|
||||
public void failureAnalysisIsPerformed() {
|
||||
FailureAnalysis failureAnalysis = performAnalysis(TestConfiguration.class);
|
||||
assertThat(failureAnalysis.getDescription()).contains(
|
||||
"'spring.datasource.url' is not specified",
|
||||
"no embedded datasource could be auto-configured",
|
||||
"'url' attribute is not specified",
|
||||
"no embedded datasource could be configured",
|
||||
"Failed to determine a suitable driver class");
|
||||
assertThat(failureAnalysis.getAction()).contains(
|
||||
"If you want an embedded database (H2, HSQL or Derby), please put it on the classpath",
|
||||
|
||||
Reference in New Issue
Block a user