From 0348889fd7c948c34cda472cbc370d7704e762fd Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 12 Feb 2018 10:02:51 -0800 Subject: [PATCH] Polish --- .../endpoint/jmx/JmxEndpointProperties.java | 1 - ...ewRelicMetricsExportAutoConfiguration.java | 6 ----- .../endpoint/invoke/InvocationContext.java | 1 - .../client/MetricsRestTemplateCustomizer.java | 2 +- .../endpoint/web/test/WebEndpointRunners.java | 2 +- .../MongoReactiveDataAutoConfiguration.java | 3 ++- ...DataSourceBeanCreationFailureAnalyzer.java | 22 +++++++++++++------ .../jdbc/DataSourceProperties.java | 3 +-- .../main/asciidoc/spring-boot-features.adoc | 2 ++ .../test/web/client/TestRestTemplate.java | 7 +++--- .../CorsSampleActuatorApplicationTests.java | 2 +- 11 files changed, 27 insertions(+), 24 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointProperties.java index ccdc50610a3..77f92789569 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointProperties.java @@ -82,7 +82,6 @@ public class JmxEndpointProperties { return this.staticNames; } - public static class Exposure { /** diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.java index cc4b9e8addc..e371040e180 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.java @@ -47,12 +47,6 @@ import org.springframework.context.annotation.Configuration; @EnableConfigurationProperties(NewRelicProperties.class) public class NewRelicMetricsExportAutoConfiguration { - @Bean - @ConditionalOnMissingBean - public Clock micrometerClock() { - return Clock.SYSTEM; - } - @Bean @ConditionalOnMissingBean public NewRelicConfig newRelicConfig(NewRelicProperties props) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoke/InvocationContext.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoke/InvocationContext.java index 9d758c2a2d3..0b03d72b21f 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoke/InvocationContext.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoke/InvocationContext.java @@ -36,7 +36,6 @@ public class InvocationContext { /** * Creates a new context for an operation being invoked by the given {@code principal} * with the given available {@code arguments}. - * * @param principal the principal invoking the operation. May be {@code null} * @param arguments the arguments available to the operation. Never {@code null} */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/MetricsRestTemplateCustomizer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/MetricsRestTemplateCustomizer.java index 9c667805987..ae5de23c0d2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/MetricsRestTemplateCustomizer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/MetricsRestTemplateCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointRunners.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointRunners.java index 631383653f5..63cc852d31c 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointRunners.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/test/WebEndpointRunners.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.java index 21768f878f0..de16566c56e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.java @@ -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; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBeanCreationFailureAnalyzer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBeanCreationFailureAnalyzer.java index c6121e12f33..38fdda176c5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBeanCreationFailureAnalyzer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBeanCreationFailureAnalyzer.java @@ -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() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java index b09c421e6f0..f39a78151b1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java @@ -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; diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index f9ecab7cf8e..426376524be 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -5990,6 +5990,8 @@ TIP: Do not forget to add `@RunWith(SpringRunner.class)` to your test. Otherwise annotations are ignored. + +[[boot-features-testing-spring-boot-applications-detecting-web-app-type]] ==== Detecting Web Application Type If Spring MVC is available, a regular MVC-based application context is configured. If you have only Spring WebFlux, we'll detect that and configure a WebFlux-based application diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java index 980ca862d2f..656740cdb89 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java @@ -125,9 +125,10 @@ public class TestRestTemplate { * @param httpClientOptions client options to use if the Apache HTTP Client is used * @since 2.0.0 */ - public TestRestTemplate(RestTemplateBuilder restTemplateBuilder, String username, String password, - HttpClientOption... httpClientOptions) { - this(buildRestTemplate(restTemplateBuilder), username, password, httpClientOptions); + public TestRestTemplate(RestTemplateBuilder restTemplateBuilder, String username, + String password, HttpClientOption... httpClientOptions) { + this(buildRestTemplate(restTemplateBuilder), username, password, + httpClientOptions); } private TestRestTemplate(RestTemplate restTemplate, String username, String password, diff --git a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/test/java/sample/actuator/customsecurity/CorsSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/test/java/sample/actuator/customsecurity/CorsSampleActuatorApplicationTests.java index 0e04448553a..2d8bed9c842 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/test/java/sample/actuator/customsecurity/CorsSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/test/java/sample/actuator/customsecurity/CorsSampleActuatorApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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.