Polish
This commit is contained in:
@@ -48,7 +48,8 @@ import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
@Configuration
|
||||
@ConditionalOnClass({ MongoClient.class, ReactiveMongoTemplate.class })
|
||||
@EnableConfigurationProperties(MongoProperties.class)
|
||||
@AutoConfigureAfter({ MongoReactiveAutoConfiguration.class, MongoDataAutoConfiguration.class })
|
||||
@AutoConfigureAfter({ MongoReactiveAutoConfiguration.class,
|
||||
MongoDataAutoConfiguration.class })
|
||||
public class MongoReactiveDataAutoConfiguration {
|
||||
|
||||
private final MongoProperties properties;
|
||||
|
||||
@@ -51,17 +51,24 @@ class DataSourceBeanCreationFailureAnalyzer
|
||||
}
|
||||
|
||||
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();
|
||||
boolean datasourceUrlSpecified = this.environment.containsProperty(
|
||||
"spring.datasource.url");
|
||||
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(String.format(
|
||||
"no embedded datasource could be auto-configured.%n"));
|
||||
description.append(
|
||||
String.format("no embedded datasource could be auto-configured.%n"));
|
||||
description.append(String.format("%nReason: %s%n", cause.getMessage()));
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
private String getAction(DataSourceBeanCreationException cause) {
|
||||
StringBuilder action = new StringBuilder();
|
||||
action.append(String.format("Consider the following:%n"));
|
||||
if (EmbeddedDatabaseConnection.NONE == cause.getConnection()) {
|
||||
@@ -69,11 +76,12 @@ class DataSourceBeanCreationFailureAnalyzer
|
||||
+ "Derby), please put it on the classpath.%n"));
|
||||
}
|
||||
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 "
|
||||
+ "profile you may need to activate it").append(getActiveProfiles());
|
||||
return new FailureAnalysis(description.toString(), action.toString(), cause);
|
||||
return action.toString();
|
||||
}
|
||||
|
||||
private String getActiveProfiles() {
|
||||
|
||||
@@ -47,8 +47,7 @@ import org.springframework.util.StringUtils;
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.datasource")
|
||||
public class DataSourceProperties
|
||||
implements BeanClassLoaderAware, InitializingBean {
|
||||
public class DataSourceProperties implements BeanClassLoaderAware, InitializingBean {
|
||||
|
||||
private ClassLoader classLoader;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user