|
|
|
@ -51,17 +51,24 @@ class DataSourceBeanCreationFailureAnalyzer |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private FailureAnalysis getFailureAnalysis(DataSourceBeanCreationException cause) { |
|
|
|
private FailureAnalysis getFailureAnalysis(DataSourceBeanCreationException cause) { |
|
|
|
|
|
|
|
String description = getDescription(cause); |
|
|
|
|
|
|
|
String action = getAction(cause); |
|
|
|
|
|
|
|
return new FailureAnalysis(description, action, cause); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getDescription(DataSourceBeanCreationException cause) { |
|
|
|
StringBuilder description = new StringBuilder(); |
|
|
|
StringBuilder description = new StringBuilder(); |
|
|
|
boolean datasourceUrlSpecified = this.environment.containsProperty( |
|
|
|
|
|
|
|
"spring.datasource.url"); |
|
|
|
|
|
|
|
description.append("Failed to auto-configure a DataSource: "); |
|
|
|
description.append("Failed to auto-configure a DataSource: "); |
|
|
|
if (!datasourceUrlSpecified) { |
|
|
|
if (!this.environment.containsProperty("spring.datasource.url")) { |
|
|
|
description.append("'spring.datasource.url' is not specified and "); |
|
|
|
description.append("'spring.datasource.url' is not specified and "); |
|
|
|
} |
|
|
|
} |
|
|
|
description.append(String.format( |
|
|
|
description.append( |
|
|
|
"no embedded datasource could be auto-configured.%n")); |
|
|
|
String.format("no embedded datasource could be auto-configured.%n")); |
|
|
|
description.append(String.format("%nReason: %s%n", cause.getMessage())); |
|
|
|
description.append(String.format("%nReason: %s%n", cause.getMessage())); |
|
|
|
|
|
|
|
return description.toString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getAction(DataSourceBeanCreationException cause) { |
|
|
|
StringBuilder action = new StringBuilder(); |
|
|
|
StringBuilder action = new StringBuilder(); |
|
|
|
action.append(String.format("Consider the following:%n")); |
|
|
|
action.append(String.format("Consider the following:%n")); |
|
|
|
if (EmbeddedDatabaseConnection.NONE == cause.getConnection()) { |
|
|
|
if (EmbeddedDatabaseConnection.NONE == cause.getConnection()) { |
|
|
|
@ -69,11 +76,12 @@ class DataSourceBeanCreationFailureAnalyzer |
|
|
|
+ "Derby), please put it on the classpath.%n")); |
|
|
|
+ "Derby), please put it on the classpath.%n")); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
action.append(String.format("\tReview the configuration of %s%n.", cause.getConnection())); |
|
|
|
action.append(String.format("\tReview the configuration of %s%n.", |
|
|
|
|
|
|
|
cause.getConnection())); |
|
|
|
} |
|
|
|
} |
|
|
|
action.append("\tIf you have database settings to be loaded from a particular " |
|
|
|
action.append("\tIf you have database settings to be loaded from a particular " |
|
|
|
+ "profile you may need to activate it").append(getActiveProfiles()); |
|
|
|
+ "profile you may need to activate it").append(getActiveProfiles()); |
|
|
|
return new FailureAnalysis(description.toString(), action.toString(), cause); |
|
|
|
return action.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String getActiveProfiles() { |
|
|
|
private String getActiveProfiles() { |
|
|
|
|