From 6193b640a4ba69ee0ca43faf440a6e34acf3dfaf Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 2 Sep 2015 20:17:28 -0700 Subject: [PATCH] Polish --- CONTRIBUTING.adoc | 1 - .../PublicMetricsAutoConfiguration.java | 4 +- .../autoconfigure/ShellProperties.java | 4 +- .../PublicMetricsAutoConfigurationTests.java | 21 +-- .../MessageSourceAutoConfiguration.java | 34 ++-- .../autoconfigure/SpringBootApplication.java | 14 +- .../jdbc/DataSourceProperties.java | 5 +- .../autoconfigure/orm/jpa/JpaProperties.java | 4 +- .../AuthenticationManagerConfiguration.java | 11 +- .../security/SecurityAutoConfiguration.java | 3 +- .../security/SecurityDataConfiguration.java | 3 +- .../SecurityFilterAutoConfiguration.java | 12 +- .../security/SecurityProperties.java | 6 +- .../ConditionalOnEnabledResourceChain.java | 3 +- .../web/OnEnabledResourceChainCondition.java | 16 +- .../autoconfigure/web/ServerProperties.java | 4 +- .../web/WebMvcAutoConfiguration.java | 4 +- .../MessageSourceAutoConfigurationTests.java | 8 +- .../batch/BatchAutoConfigurationTests.java | 14 +- .../JobLauncherCommandLineRunnerTests.java | 3 + .../DataSourceAutoConfigurationTests.java | 12 +- .../SecurityAutoConfigurationTests.java | 26 ++- .../ThymeleafAutoConfigurationTests.java | 6 +- .../VelocityAutoConfigurationTests.java | 6 +- ...onditionalOnEnabledResourceChainTests.java | 2 - .../init/ProjectGenerationRequest.java | 2 +- .../cli/command/init/InitCommandTests.java | 6 +- .../init/ProjectGenerationRequestTests.java | 12 +- .../autoconfigure/DevToolsProperties.java | 4 +- .../DevToolsPropertiesTests.java | 8 +- .../LocalDevToolsAutoConfigurationTests.java | 1 + spring-boot-docs/src/main/asciidoc/howto.adoc | 23 ++- .../main/asciidoc/spring-boot-features.adoc | 22 ++- .../spring-boot-sample-cache/README.adoc | 1 - .../spring-boot-sample-cache/pom.xml | 2 +- .../boot/SpringApplication.java | 4 +- .../boot/bind/OriginCapablePropertyValue.java | 8 + .../boot/bind/RelaxedDataBinder.java | 161 ++++++++++-------- .../embedded/FilterRegistrationBean.java | 4 +- .../ConfigurationPropertiesBinding.java | 1 + ...urationPropertiesBindingPostProcessor.java | 64 ++++--- .../web/OrderedCharacterEncodingFilter.java | 4 +- .../web/OrderedHiddenHttpMethodFilter.java | 2 +- .../web/OrderedHttpPutFormContentFilter.java | 2 +- .../boot/env/EnvironmentPostProcessor.java | 1 - .../logging/LoggingApplicationListener.java | 3 +- .../web/servlet/ServletComponentHandler.java | 12 +- ...vletComponentRegisteringPostProcessor.java | 36 ++-- .../web/servlet/ServletComponentScan.java | 4 +- .../ServletComponentScanRegistrar.java | 20 +-- .../boot/web/servlet/WebFilterHandler.java | 2 +- .../boot/web/servlet/WebListenerHandler.java | 2 +- .../boot/web/servlet/WebServletHandler.java | 2 +- .../boot/bind/ConverterBindingTests.java | 11 +- .../boot/bind/RelaxedDataBinderTests.java | 20 +-- ...onPropertiesBindingPostProcessorTests.java | 3 +- .../ServletComponentScanIntegrationTests.java | 1 + 57 files changed, 364 insertions(+), 310 deletions(-) diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 45716e94d3..1f84d59b40 100755 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -6,7 +6,6 @@ something, or simply want to hack on the code this document should help you get == Using GitHub issues - We use GitHub issues to track bugs and enhancements. If you have a general usage question please ask on http://stackoverflow.com[Stack Overflow]. The Spring Boot team and the broader community monitor the http://stackoverflow.com/tags/spring-boot[`spring-boot`] diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java index 11535509b3..f0a8e53521 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java @@ -66,8 +66,8 @@ import org.springframework.lang.UsesJava7; @Configuration @AutoConfigureBefore(EndpointAutoConfiguration.class) @AutoConfigureAfter({ DataSourceAutoConfiguration.class, CacheAutoConfiguration.class, - MetricRepositoryAutoConfiguration.class, CacheStatisticsAutoConfiguration.class, - IntegrationAutoConfiguration.class }) + MetricRepositoryAutoConfiguration.class, CacheStatisticsAutoConfiguration.class, + IntegrationAutoConfiguration.class }) public class PublicMetricsAutoConfiguration { @Autowired(required = false) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ShellProperties.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ShellProperties.java index 930dd345a4..e823a059da 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ShellProperties.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ShellProperties.java @@ -42,8 +42,8 @@ public class ShellProperties { private static Log logger = LogFactory.getLog(ShellProperties.class); /** - * Authentication type. Auto-detected according to the environment (i.e. if - * Spring Security is available, "spring" is used by default). + * Authentication type. Auto-detected according to the environment (i.e. if Spring + * Security is available, "spring" is used by default). */ private String auth = "simple"; diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java index 4c1594f1b6..784e3fe58c 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java @@ -16,14 +16,6 @@ package org.springframework.boot.actuate.autoconfigure; -import static org.hamcrest.Matchers.hasKey; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - import java.sql.Connection; import java.sql.SQLException; import java.util.Collection; @@ -67,6 +59,14 @@ import org.springframework.util.SocketUtils; import com.zaxxer.hikari.HikariDataSource; +import static org.hamcrest.Matchers.hasKey; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + /** * Tests for {@link PublicMetricsAutoConfiguration}. * @@ -150,7 +150,7 @@ public class PublicMetricsAutoConfigurationTests { jdbcTemplate.execute(new ConnectionCallback() { @Override public Void doInConnection(Connection connection) throws SQLException, - DataAccessException { + DataAccessException { return null; } }); @@ -246,7 +246,8 @@ public class PublicMetricsAutoConfigurationTests { } context.register(DataSourcePoolMetadataProvidersConfiguration.class, CacheStatisticsAutoConfiguration.class, - PublicMetricsAutoConfiguration.class, MockEmbeddedServletContainerFactory.class); + PublicMetricsAutoConfiguration.class, + MockEmbeddedServletContainerFactory.class); context.refresh(); this.context = context; } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfiguration.java index f8fa9e4c2f..8fa04d6598 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfiguration.java @@ -16,9 +16,6 @@ package org.springframework.boot.autoconfigure; -import static org.springframework.util.StringUtils.commaDelimitedListToStringArray; -import static org.springframework.util.StringUtils.trimAllWhitespace; - import java.io.IOException; import java.nio.charset.Charset; import java.util.Iterator; @@ -44,6 +41,9 @@ import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.util.ConcurrentReferenceHashMap; import org.springframework.util.StringUtils; +import static org.springframework.util.StringUtils.commaDelimitedListToStringArray; +import static org.springframework.util.StringUtils.trimAllWhitespace; + /** * {@link EnableAutoConfiguration Auto-configuration} for {@link MessageSource}. * @@ -52,7 +52,7 @@ import org.springframework.util.StringUtils; * @author EddĂș MelĂ©ndez */ @Configuration -@ConditionalOnMissingBean(value=MessageSource.class, search=SearchStrategy.CURRENT) +@ConditionalOnMissingBean(value = MessageSource.class, search = SearchStrategy.CURRENT) @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @Conditional(ResourceBundleCondition.class) @EnableConfigurationProperties @@ -81,8 +81,8 @@ public class MessageSourceAutoConfiguration { /** * Set whether to fall back to the system Locale if no files for a specific Locale - * have been found. if this is turned off, the only fallback will be the default - * file (e.g. "messages.properties" for basename "messages"). + * have been found. if this is turned off, the only fallback will be the default file + * (e.g. "messages.properties" for basename "messages"). */ private boolean fallbackToSystemLocale = true; @@ -91,7 +91,7 @@ public class MessageSourceAutoConfiguration { ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); if (StringUtils.hasText(this.basename)) { messageSource - .setBasenames(commaDelimitedListToStringArray(trimAllWhitespace(this.basename))); + .setBasenames(commaDelimitedListToStringArray(trimAllWhitespace(this.basename))); } if (this.encoding != null) { messageSource.setDefaultEncoding(this.encoding.name()); @@ -167,7 +167,7 @@ public class MessageSourceAutoConfiguration { private Resource[] getResources(ClassLoader classLoader, String name) { try { return new SkipPatternPathMatchingResourcePatternResolver(classLoader) - .getResources("classpath*:" + name + "*.properties"); + .getResources("classpath*:" + name + "*.properties"); } catch (Exception ex) { return NO_RESOURCES; @@ -181,7 +181,7 @@ public class MessageSourceAutoConfiguration { * contain messages.properties. */ private static class SkipPatternPathMatchingResourcePatternResolver extends - PathMatchingResourcePatternResolver { + PathMatchingResourcePatternResolver { private static final ClassLoader ROOT_CLASSLOADER; static { @@ -198,14 +198,14 @@ public class MessageSourceAutoConfiguration { } private static final String[] SKIPPED = { "aspectjweaver-", "hibernate-core-", - "hsqldb-", "jackson-annotations-", "jackson-core-", "jackson-databind-", - "javassist-", "snakeyaml-", "spring-aop-", "spring-beans-", - "spring-boot-", "spring-boot-actuator-", "spring-boot-autoconfigure-", - "spring-core-", "spring-context-", "spring-data-commons-", - "spring-expression-", "spring-jdbc-", "spring-orm-", "spring-tx-", - "spring-web-", "spring-webmvc-", "tomcat-embed-", "joda-time-", - "hibernate-entitymanager-", "hibernate-validator-", "logback-classic-", - "logback-core-", "thymeleaf-" }; + "hsqldb-", "jackson-annotations-", "jackson-core-", "jackson-databind-", + "javassist-", "snakeyaml-", "spring-aop-", "spring-beans-", + "spring-boot-", "spring-boot-actuator-", "spring-boot-autoconfigure-", + "spring-core-", "spring-context-", "spring-data-commons-", + "spring-expression-", "spring-jdbc-", "spring-orm-", "spring-tx-", + "spring-web-", "spring-webmvc-", "tomcat-embed-", "joda-time-", + "hibernate-entitymanager-", "hibernate-validator-", "logback-classic-", + "logback-core-", "thymeleaf-" }; public SkipPatternPathMatchingResourcePatternResolver(ClassLoader classLoader) { super(classLoader); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java index bc34228f59..d2f6d7a1ed 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java @@ -63,9 +63,8 @@ public @interface SpringBootApplication { String[] excludeName() default {}; /** - * Base packages to scan for annotated components. - *

Use {@link #scanBasePackageClasses} for a type-safe alternative to - * String-based package names. + * Base packages to scan for annotated components. Use {@link #scanBasePackageClasses} + * for a type-safe alternative to String-based package names. * @return base packages to scan * @since 1.3.0 */ @@ -73,10 +72,11 @@ public @interface SpringBootApplication { String[] scanBasePackages() default {}; /** - * Type-safe alternative to {@link #scanBasePackages} for specifying the packages - * to scan for annotated components. The package of each class specified will be scanned. - *

Consider creating a special no-op marker class or interface in each package - * that serves no purpose other than being referenced by this attribute. + * Type-safe alternative to {@link #scanBasePackages} for specifying the packages to + * scan for annotated components. The package of each class specified will be scanned. + *

+ * Consider creating a special no-op marker class or interface in each package that + * serves no purpose other than being referenced by this attribute. * @return base packages to scan * @since 1.3.0 */ diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java index 17db153f82..d7dcae8732 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java @@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.jdbc; import java.nio.charset.Charset; import java.util.LinkedHashMap; import java.util.Map; + import javax.sql.DataSource; import org.springframework.beans.factory.BeanClassLoaderAware; @@ -48,8 +49,8 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB private String name = "testdb"; /** - * Fully qualified name of the connection pool implementation to use. By default, - * it is auto-detected from the classpath. + * Fully qualified name of the connection pool implementation to use. By default, it + * is auto-detected from the classpath. */ private Class type; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java index 37fa29b2ab..8babe4a5b8 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java @@ -134,8 +134,8 @@ public class JpaProperties { /** * DDL mode. This is actually a shortcut for the "hibernate.hbm2ddl.auto" - * property. Default to "create-drop" when using an embedded database, - * "none" otherwise. + * property. Default to "create-drop" when using an embedded database, "none" + * otherwise. */ private String ddlAuto; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/AuthenticationManagerConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/AuthenticationManagerConfiguration.java index edaf23f606..ebaa9d55cf 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/AuthenticationManagerConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/AuthenticationManagerConfiguration.java @@ -69,7 +69,6 @@ public class AuthenticationManagerConfiguration { private static Log logger = LogFactory .getLog(AuthenticationManagerConfiguration.class); - @SuppressWarnings("unused") @Autowired private List dependencies; @@ -112,7 +111,7 @@ public class AuthenticationManagerConfiguration { */ @Order(Ordered.LOWEST_PRECEDENCE - 100) private static class SpringBootAuthenticationConfigurerAdapter extends - GlobalAuthenticationConfigurerAdapter { + GlobalAuthenticationConfigurerAdapter { private final SecurityProperties securityProperties; @@ -152,7 +151,7 @@ public class AuthenticationManagerConfiguration { * */ private static class DefaultInMemoryUserDetailsManagerConfigurer extends - InMemoryUserDetailsManagerConfigurer { + InMemoryUserDetailsManagerConfigurer { private final SecurityProperties securityProperties; @@ -169,7 +168,7 @@ public class AuthenticationManagerConfiguration { User user = this.securityProperties.getUser(); if (user.isDefaultPassword()) { logger.info("\n\nUsing default security password: " + user.getPassword() - + "\n"); + + "\n"); } Set roles = new LinkedHashSet(user.getRole()); withUser(user.getName()).password(user.getPassword()).roles( @@ -197,7 +196,7 @@ public class AuthenticationManagerConfiguration { */ @Component protected static class AuthenticationManagerConfigurationListener implements - SmartInitializingSingleton { + SmartInitializingSingleton { @Autowired private AuthenticationEventPublisher eventPublisher; @@ -219,7 +218,7 @@ public class AuthenticationManagerConfiguration { private void configureAuthenticationManager(AuthenticationManager manager) { if (manager instanceof ProviderManager) { ((ProviderManager) manager) - .setAuthenticationEventPublisher(this.eventPublisher); + .setAuthenticationEventPublisher(this.eventPublisher); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java index 96406f4fd6..62adcff469 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java @@ -50,8 +50,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur @EnableConfigurationProperties @Import({ SpringBootWebSecurityConfiguration.class, AuthenticationManagerConfiguration.class, - BootGlobalAuthenticationConfiguration.class, - SecurityDataConfiguration.class }) + BootGlobalAuthenticationConfiguration.class, SecurityDataConfiguration.class }) public class SecurityAutoConfiguration { @Bean diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java index be9d2a6ee1..83cfcad1f9 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.boot.autoconfigure.security; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -39,4 +40,4 @@ public class SecurityDataConfiguration { return new SecurityEvaluationContextExtension(); } -} \ No newline at end of file +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityFilterAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityFilterAutoConfiguration.java index bdb5b39bb5..e2ab089561 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityFilterAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityFilterAutoConfiguration.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.boot.autoconfigure.security; import javax.servlet.Filter; @@ -44,16 +45,17 @@ import org.springframework.security.web.context.AbstractSecurityWebApplicationIn @AutoConfigureAfter(SpringBootWebSecurityConfiguration.class) public class SecurityFilterAutoConfiguration { + private static final String DEFAULT_FILTER_NAME = AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME; + @Bean - @ConditionalOnBean(name = AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME) + @ConditionalOnBean(name = DEFAULT_FILTER_NAME) public FilterRegistrationBean securityFilterChainRegistration( - @Qualifier(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME) Filter securityFilter, + @Qualifier(DEFAULT_FILTER_NAME) Filter securityFilter, SecurityProperties securityProperties) { FilterRegistrationBean registration = new FilterRegistrationBean(securityFilter); registration.setOrder(securityProperties.getFilterOrder()); - registration - .setName(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME); + registration.setName(DEFAULT_FILTER_NAME); return registration; } -} \ No newline at end of file +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java index 89d4ec5845..8f21bc9d8a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java @@ -40,8 +40,7 @@ public class SecurityProperties implements SecurityPrerequisite { * useful place to put user-defined access rules if you want to override the default * access rules. */ - public static final int ACCESS_OVERRIDE_ORDER = SecurityProperties.BASIC_AUTH_ORDER - - 2; + public static final int ACCESS_OVERRIDE_ORDER = SecurityProperties.BASIC_AUTH_ORDER - 2; /** * Order applied to the WebSecurityConfigurerAdapter that is used to configure basic @@ -62,8 +61,7 @@ public class SecurityProperties implements SecurityPrerequisite { * other filters registered with the container). There is no connection between this * and the @Order on a WebSecurityConfigurer. */ - public static final int DEFAULT_FILTER_ORDER = FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - - 100; + public static final int DEFAULT_FILTER_ORDER = FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100; /** * Enable secure channel for all requests. diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChain.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChain.java index 079cd985fd..2b34163e2f 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChain.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChain.java @@ -31,9 +31,10 @@ import org.springframework.context.annotation.Conditional; * @author Stephane Nicoll * @since 1.3.0 */ -@Target({ElementType.TYPE, ElementType.METHOD}) +@Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @Documented @Conditional(OnEnabledResourceChainCondition.class) public @interface ConditionalOnEnabledResourceChain { + } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java index 83e0da38b3..f79bea14dd 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java @@ -34,14 +34,16 @@ import org.springframework.core.type.AnnotatedTypeMetadata; class OnEnabledResourceChainCondition extends SpringBootCondition { @Override - public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { - ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment(); - ResourceProperties resourceProperties = new ResourceProperties(); - RelaxedDataBinder binder = new RelaxedDataBinder(resourceProperties, "spring.resources"); + public ConditionOutcome getMatchOutcome(ConditionContext context, + AnnotatedTypeMetadata metadata) { + ConfigurableEnvironment environment = (ConfigurableEnvironment) context + .getEnvironment(); + ResourceProperties properties = new ResourceProperties(); + RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources"); binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources())); - - Boolean match = resourceProperties.getChain().getEnabled(); - return new ConditionOutcome(match, "Resource chain is " + (match ? "enabled" : "disabled" + ")")); + Boolean match = properties.getChain().getEnabled(); + return new ConditionOutcome(match, "Resource chain is " + + (match ? "enabled" : "disabled" + ")")); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 846eb4c74e..9251a9dc6c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -283,7 +283,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord } if (container instanceof TomcatEmbeddedServletContainerFactory) { getTomcat() - .customizeTomcat((TomcatEmbeddedServletContainerFactory) container); + .customizeTomcat((TomcatEmbeddedServletContainerFactory) container); } if (container instanceof UndertowEmbeddedServletContainerFactory) { getUndertow().customizeUndertow( @@ -1015,7 +1015,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord * configuration. */ private static class SessionConfiguringInitializer implements - ServletContextInitializer { + ServletContextInitializer { private final Session session; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java index 1626aeb89c..5fa2ae4e4c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java @@ -96,7 +96,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; @Configuration @ConditionalOnWebApplication @ConditionalOnClass({ Servlet.class, DispatcherServlet.class, - WebMvcConfigurerAdapter.class }) + WebMvcConfigurerAdapter.class }) @ConditionalOnMissingBean(WebMvcConfigurationSupport.class) @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE + 10) @AutoConfigureAfter(DispatcherServletAutoConfiguration.class) @@ -313,7 +313,7 @@ public class WebMvcAutoConfiguration { public ResourceHttpRequestHandler faviconRequestHandler() { ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler(); requestHandler - .setLocations(this.resourceProperties.getFaviconLocations()); + .setLocations(this.resourceProperties.getFaviconLocations()); return requestHandler; } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfigurationTests.java index 10621de081..76d76ddaf3 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/MessageSourceAutoConfigurationTests.java @@ -43,8 +43,8 @@ public class MessageSourceAutoConfigurationTests { @After public void closeContext() { - if (context != null) { - context.close(); + if (this.context != null) { + this.context.close(); } } @@ -72,7 +72,8 @@ public class MessageSourceAutoConfigurationTests { @Test public void testMultipleMessageSourceCreated() throws Exception { load("spring.messages.basename:test/messages,test/messages2"); - assertEquals("bar", this.context.getMessage("foo", null, "Foo message", Locale.UK)); + assertEquals("bar", + this.context.getMessage("foo", null, "Foo message", Locale.UK)); assertEquals("bar-bar", this.context.getMessage("foo-foo", null, "Foo-Foo message", Locale.UK)); } @@ -124,4 +125,5 @@ public class MessageSourceAutoConfigurationTests { protected static class Config { } + } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java index a66e70982c..5433783865 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java @@ -216,17 +216,17 @@ public class BatchAutoConfigurationTests { public void testRenamePrefix() throws Exception { this.context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, - "spring.datasource.name:batchtest", - "spring.batch.schema:classpath:batch/custom-schema-hsql.sql", - "spring.batch.tablePrefix:PREFIX_"); + "spring.datasource.name:batchtest", + "spring.batch.schema:classpath:batch/custom-schema-hsql.sql", + "spring.batch.tablePrefix:PREFIX_"); this.context.register(TestConfiguration.class, - EmbeddedDataSourceConfiguration.class, - HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); + EmbeddedDataSourceConfiguration.class, + HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class, + PropertyPlaceholderAutoConfiguration.class); this.context.refresh(); assertNotNull(this.context.getBean(JobLauncher.class)); assertEquals(0, new JdbcTemplate(this.context.getBean(DataSource.class)) - .queryForList("select * from PREFIX_JOB_EXECUTION").size()); + .queryForList("select * from PREFIX_JOB_EXECUTION").size()); JobExplorer jobExplorer = this.context.getBean(JobExplorer.class); assertEquals(0, jobExplorer.findRunningJobExecutions("test").size()); JobRepository jobRepository = this.context.getBean(JobRepository.class); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java index 14612fb5c8..481e8604af 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java @@ -164,7 +164,9 @@ public class JobLauncherCommandLineRunnerTests { protected static class BatchConfiguration implements BatchConfigurer { private ResourcelessTransactionManager transactionManager = new ResourcelessTransactionManager(); + private JobRepository jobRepository; + private MapJobRepositoryFactoryBean jobRepositoryFactory = new MapJobRepositoryFactoryBean( this.transactionManager); @@ -198,6 +200,7 @@ public class JobLauncherCommandLineRunnerTests { public JobExplorer getJobExplorer() throws Exception { return new MapJobExplorerFactoryBean(this.jobRepositoryFactory).getObject(); } + } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java index f7be56ef5d..e89b12bdad 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java @@ -26,14 +26,13 @@ import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; import java.util.Random; import java.util.logging.Logger; + import javax.sql.DataSource; -import com.zaxxer.hikari.HikariDataSource; import org.apache.commons.dbcp.BasicDataSource; import org.junit.After; import org.junit.Before; import org.junit.Test; - import org.springframework.beans.factory.BeanCreationException; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.test.EnvironmentTestUtils; @@ -43,6 +42,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; +import com.zaxxer.hikari.HikariDataSource; + import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -158,8 +159,8 @@ public class DataSourceAutoConfigurationTests { public void explicitType() { EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.driverClassName:org.hsqldb.jdbcDriver", - "spring.datasource.url:jdbc:hsqldb:mem:testdb", - "spring.datasource.type:" + HikariDataSource.class.getName()); + "spring.datasource.url:jdbc:hsqldb:mem:testdb", "spring.datasource.type:" + + HikariDataSource.class.getName()); this.context.register(DataSourceAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); this.context.refresh(); @@ -271,7 +272,8 @@ public class DataSourceAutoConfigurationTests { } - @SuppressWarnings("unused") // see testExplicitDriverClassClearsUserName + @SuppressWarnings("unused") + // see testExplicitDriverClassClearsUserName public static class DatabaseDriver implements Driver { @Override diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java index 80a6118705..3f0dcb96dc 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java @@ -16,12 +16,6 @@ package org.springframework.boot.autoconfigure.security; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.util.List; import org.junit.After; @@ -63,6 +57,12 @@ import org.springframework.security.web.FilterChainProxy; import org.springframework.security.web.SecurityFilterChain; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Tests for {@link SecurityAutoConfiguration}. * @@ -105,7 +105,7 @@ public class SecurityAutoConfigurationTests { PropertyPlaceholderAutoConfiguration.class); this.context.refresh(); assertEquals( - FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER-100, + FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100, this.context.getBean("securityFilterChainRegistration", FilterRegistrationBean.class).getOrder()); } @@ -136,7 +136,7 @@ public class SecurityAutoConfigurationTests { PropertyPlaceholderAutoConfiguration.class); this.context.refresh(); assertEquals( - FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER-100, + FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER - 100, this.context.getBean("securityFilterChainRegistration", FilterRegistrationBean.class).getOrder()); } @@ -355,16 +355,14 @@ public class SecurityAutoConfigurationTests { public void testSecurityEvaluationContextExtensionSupport() { this.context = new AnnotationConfigWebApplicationContext(); this.context.setServletContext(new MockServletContext()); - this.context.register(AuthenticationManagerCustomizer.class, SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class); this.context.refresh(); - assertNotNull(this.context.getBean(SecurityEvaluationContextExtension.class)); } private static final class AuthenticationListener implements - ApplicationListener { + ApplicationListener { private ApplicationEvent event; @@ -410,7 +408,7 @@ public class SecurityAutoConfigurationTests { @Configuration protected static class WorkaroundSecurityCustomizer extends - WebSecurityConfigurerAdapter { + WebSecurityConfigurerAdapter { @Autowired private AuthenticationManagerBuilder builder; @@ -435,7 +433,7 @@ public class SecurityAutoConfigurationTests { @Configuration @Order(-1) protected static class AuthenticationManagerCustomizer extends - GlobalAuthenticationConfigurerAdapter { + GlobalAuthenticationConfigurerAdapter { @Override public void init(AuthenticationManagerBuilder auth) throws Exception { @@ -446,7 +444,7 @@ public class SecurityAutoConfigurationTests { @Configuration protected static class UserDetailsSecurityCustomizer extends - WebSecurityConfigurerAdapter { + WebSecurityConfigurerAdapter { private UserDetailsService userDetails; diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java index 57acc8da3c..6b19c681e6 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java @@ -200,11 +200,13 @@ public class ThymeleafAutoConfigurationTests { this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); this.context.refresh(); - assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class).size()); + assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class) + .size()); } @Test - public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() throws Exception { + public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() + throws Exception { this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(this.context, diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfigurationTests.java index 6738ca12c6..7b1cf6e8b5 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfigurationTests.java @@ -193,11 +193,13 @@ public class VelocityAutoConfigurationTests { @Test public void registerResourceHandlingFilterDisabledByDefault() throws Exception { registerAndRefreshContext(); - assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class).size()); + assertEquals(0, this.context.getBeansOfType(ResourceUrlEncodingFilter.class) + .size()); } @Test - public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() throws Exception { + public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() + throws Exception { registerAndRefreshContext("spring.resources.chain.enabled:true"); assertNotNull(this.context.getBean(ResourceUrlEncodingFilter.class)); } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChainTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChainTests.java index e097d96590..77122def5c 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChainTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChainTests.java @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.web; import org.junit.After; import org.junit.Test; - import org.springframework.boot.test.EnvironmentTestUtils; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -71,7 +70,6 @@ public class ConditionalOnEnabledResourceChainTests { assertTrue(this.context.containsBean("foo")); } - private void load(String... environment) { this.context.register(Config.class); EnvironmentTestUtils.addEnvironment(this.context, environment); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java index 639e9b4581..0207dff3a2 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java @@ -184,7 +184,7 @@ class ProjectGenerationRequest { * @return the package name or {@code null} */ public String getPackageName() { - return packageName; + return this.packageName; } public void setPackageName(String packageName) { diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java index 41417a754c..50062b8b95 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java @@ -266,9 +266,9 @@ public class InitCommandTests extends AbstractHttpClientMockTests { public void parseProjectOptions() throws Exception { this.handler.disableProjectGeneration(); this.command.run("-g=org.demo", "-a=acme", "-v=1.2.3-SNAPSHOT", "-n=acme-sample", - "--description=Acme sample project", "--package-name=demo.foo", "-t=ant-project", - "--build=grunt", "--format=web", "-p=war", "-j=1.9", "-l=groovy", - "-b=1.2.0.RELEASE", "-d=web,data-jpa"); + "--description=Acme sample project", "--package-name=demo.foo", + "-t=ant-project", "--build=grunt", "--format=web", "-p=war", "-j=1.9", + "-l=groovy", "-b=1.2.0.RELEASE", "-d=web,data-jpa"); assertEquals("org.demo", this.handler.lastRequest.getGroupId()); assertEquals("acme", this.handler.lastRequest.getArtifactId()); assertEquals("1.2.3-SNAPSHOT", this.handler.lastRequest.getVersion()); diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java index 7870260155..c8dc8e46d2 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java @@ -142,24 +142,21 @@ public class ProjectGenerationRequestTests { @Test public void outputCustomizeArtifactId() { this.request.setOutput("my-project"); - assertEquals( - createDefaultUrl("?artifactId=my-project&type=test-type"), + assertEquals(createDefaultUrl("?artifactId=my-project&type=test-type"), this.request.generateUrl(createDefaultMetadata())); } @Test public void outputArchiveCustomizeArtifactId() { this.request.setOutput("my-project.zip"); - assertEquals( - createDefaultUrl("?artifactId=my-project&type=test-type"), + assertEquals(createDefaultUrl("?artifactId=my-project&type=test-type"), this.request.generateUrl(createDefaultMetadata())); } @Test public void outputArchiveWithDotsCustomizeArtifactId() { this.request.setOutput("my.nice.project.zip"); - assertEquals( - createDefaultUrl("?artifactId=my.nice.project&type=test-type"), + assertEquals(createDefaultUrl("?artifactId=my.nice.project&type=test-type"), this.request.generateUrl(createDefaultMetadata())); } @@ -167,8 +164,7 @@ public class ProjectGenerationRequestTests { public void outputDoesNotOverrideCustomArtifactId() { this.request.setOutput("my-project"); this.request.setArtifactId("my-id"); - assertEquals( - createDefaultUrl("?artifactId=my-id&type=test-type"), + assertEquals(createDefaultUrl("?artifactId=my-id&type=test-type"), this.request.generateUrl(createDefaultMetadata())); } diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsProperties.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsProperties.java index ac301c5954..fb62e77156 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsProperties.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsProperties.java @@ -65,7 +65,6 @@ public class DevToolsProperties { private static final long DEFAULT_RESTART_QUIET_PERIOD = 400; - /** * Enable automatic restart. */ @@ -117,7 +116,8 @@ public class DevToolsProperties { allExclude.addAll(StringUtils.commaDelimitedListToSet(this.exclude)); } if (StringUtils.hasText(this.additionalExclude)) { - allExclude.addAll(StringUtils.commaDelimitedListToSet(this.additionalExclude)); + allExclude.addAll(StringUtils + .commaDelimitedListToSet(this.additionalExclude)); } return allExclude.toArray(new String[allExclude.size()]); } diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPropertiesTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPropertiesTests.java index a639c3d6f9..de2e65d875 100644 --- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPropertiesTests.java +++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPropertiesTests.java @@ -34,9 +34,11 @@ public class DevToolsPropertiesTests { public void additionalExcludeKeepsDefaults() { DevToolsProperties.Restart restart = this.devToolsProperties.getRestart(); restart.setAdditionalExclude("foo/**,bar/**"); - assertThat(restart.getAllExclude(), arrayContaining("META-INF/maven/**", - "META-INF/resources/**", "resources/**", "static/**", "public/**", - "templates/**", "foo/**", "bar/**")); + assertThat( + restart.getAllExclude(), + arrayContaining("META-INF/maven/**", "META-INF/resources/**", + "resources/**", "static/**", "public/**", "templates/**", + "foo/**", "bar/**")); } @Test diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java index 3b0de6383a..0580a23de3 100755 --- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java +++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java @@ -255,4 +255,5 @@ public class LocalDevToolsAutoConfigurationTests { public static class WebResourcesConfig { } + } diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 2f6f6224d7..147cd841c3 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -590,7 +590,8 @@ NOTE: The double backslashes are only required when you're using a properties fi configuration. If you are using YAML, single backslashes are sufficient and a value that's equivalent to the one shown above would be `192\.168\.\d{1,3}\.\d{1,3}`. -NOTE: You can trust all proxies by setting the `internal_proxies` to empty (but don't do this in production). +NOTE: You can trust all proxies by setting the `internal_proxies` to empty (but don't do +this in production). You can take complete control of the configuration of the `RemoteIpValve` by switching the automatic one off (i.e. set one of @@ -1164,16 +1165,17 @@ Check out {sc-spring-boot-autoconfigure}/web/WebMvcAutoConfiguration.{sc-ext}[`W {sc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{sc-ext}[`VelocityAutoConfiguration`] + [[howto-customize-view-resolvers-velocity]] === Velocity - -By default, Spring Boot configures a `VelocityViewResolver`. If you need a `VelocityLayoutViewResolver` -instead, you can easily configure your own by creating a bean with name `velocityViewResolver`. You can -also inject the `VelocityProperties` instance to apply the base defaults to your custom view resolver. +By default, Spring Boot configures a `VelocityViewResolver`. If you need a +`VelocityLayoutViewResolver` instead, you can easily configure your own by creating a bean +with name `velocityViewResolver`. You can also inject the `VelocityProperties` instance to +apply the base defaults to your custom view resolver. The following example replaces the auto-configured velocity view resolver with a -`VelocityLayoutViewResolver` defining a customized `layoutUrl` and all settings that would have been -applied from the auto-configuration: +`VelocityLayoutViewResolver` defining a customized `layoutUrl` and all settings that would +have been applied from the auto-configuration: [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- @@ -1187,6 +1189,7 @@ applied from the auto-configuration: ---- + [[howto-logging]] == Logging @@ -1456,7 +1459,6 @@ entity manager based on the presence of a bean of that type. [[howto-use-two-entity-managers]] === Use Two EntityManagers - Even if the default `EntityManagerFactory` works fine, you will need to define a new one because otherwise the presence of the second bean of that type will switch off the default. To make it easy to do that you can use the convenient `EntityManagerBuilder` @@ -1488,7 +1490,6 @@ Example: .persistenceUnit("orders") .build(); } - ---- The configuration above almost works on its own. To complete the picture you need to @@ -1501,7 +1502,6 @@ If you are using Spring Data, you need to configure `@EnableJpaRepositories` acc [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- - @Configuration @EnableJpaRepositories(basePackageClasses = Customer.class, entityManagerFactoryRef = "customerEntityManagerFactory") @@ -1515,11 +1515,10 @@ If you are using Spring Data, you need to configure `@EnableJpaRepositories` acc public class OrderConfiguration { ... } - - ---- + [[howto-use-traditional-persistence-xml]] === Use a traditional persistence.xml Spring doesn't require the use of XML to configure the JPA provider, and Spring Boot diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index e918c690db..341a84fccd 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1351,9 +1351,10 @@ https://spring.io/blog/2014/07/24/spring-framework-4-1-handling-static-web-resou and in Spring Framework's {spring-reference}/#mvc-config-static-resources[reference documentation]. ==== + + [[boot-features-spring-mvc-web-binding-initializer]] ==== ConfigurableWebBindingInitializer - Spring MVC uses a `WebBindingInitializer` to initialize a `WebDataBinder` for a particular request. If you create your own `ConfigurableWebBindingInitializer` `@Bean`, Spring Boot will automatically configure Spring MVC to use it. @@ -3419,7 +3420,8 @@ You could also specify the `hazelcast.xml` configuration file to use via configu Otherwise, Spring Boot tries to find the Hazelcast configuration from the default locations, that is `hazelcast.xml` in the working directory or at the root of the classpath. We also check if the `hazelcast.config` system property is set. Check the -http://docs.hazelcast.org/docs/latest/manual/html-single/[Hazelcast documentation] for more details. +http://docs.hazelcast.org/docs/latest/manual/html-single/[Hazelcast documentation] for +more details. NOTE: Spring Boot also has an <>. The @@ -3712,6 +3714,7 @@ TIP: A https://github.com/snicoll-demos/spring-boot-master-auto-configuration[de is available to showcase how you can create a starter step by step. + [[boot-features-understanding-auto-configured-beans]] === Understanding auto-configured beans Under the hood, auto-configuration is implemented with standard `@Configuration` classes. @@ -3818,9 +3821,9 @@ The `@ConditionalOnExpression` annotation allows configuration to be included ba result of a {spring-reference}/#expressions[SpEL expression]. + [[boot-features-custom-starter]] === Creating your own starter - A full Spring Boot starter for a library may contain the following components: * The `autoconfigure` module that contains the auto-configuration code. @@ -3831,10 +3834,11 @@ A full Spring Boot starter for a library may contain the following components: TIP: You may combine the auto-configuration code and the dependency management in a single module if you don't need to separate those two concerns. + + [[boot-features-custom-starter-naming]] ==== Naming - -Please make sure to provide a proper namespace for your starter. Do not start your module +FPlease make sure to provide a proper namespace for your starter. Do not start your module names with `spring-boot`, even if you are using a different Maven groupId. We may offer an official support for the thing you're auto-configuring in the future. @@ -3854,9 +3858,10 @@ meta-data generation>> so that IDE assistance is available for your keys as well may want to review the generated meta-data (`META-INF/spring-configuration-metadata.json`) to make sure your keys are properly documented. + + [[boot-features-custom-starter-module-autoconfigure]] ==== Autoconfigure module - The autoconfigure module contains everything that is necessary to get started with the library. It may also contain configuration keys definition (`@ConfigurationProperties`) and any callback interface that can be used to further customize how the components are @@ -3866,9 +3871,10 @@ TIP: You should mark the dependencies to the library as optional so that you can the autoconfigure module in your projects more easily. If you do it that way, the library won't be provided and boot will backoff by default. + + [[boot-features-custom-starter-module-starter]] ==== Starter module - The starter is an empty jar, really. Its only purpose is to provide the necessary dependencies to work with the library; see it as an opinionated view of what is required to get started. @@ -3879,6 +3885,8 @@ a proper set of _default_ dependencies may be hard if the number of optional dep is high as you should avoid bringing unnecessary dependencies for a typical usage of the library. + + [[boot-features-websockets]] == WebSockets Spring Boot provides WebSockets auto-configuration for embedded Tomcat (8 and 7), Jetty 9 diff --git a/spring-boot-samples/spring-boot-sample-cache/README.adoc b/spring-boot-samples/spring-boot-sample-cache/README.adoc index d0db1e646f..bbce5605f8 100644 --- a/spring-boot-samples/spring-boot-sample-cache/README.adoc +++ b/spring-boot-samples/spring-boot-sample-cache/README.adoc @@ -54,7 +54,6 @@ of the library that you want to use. - === EhCache 2.x Simply add the `net.sf.ehcache:ehcache` dependency to the project. Since there is a default `ehcache.xml` configuration file at the root of the classpath, it is automatically diff --git a/spring-boot-samples/spring-boot-sample-cache/pom.xml b/spring-boot-samples/spring-boot-sample-cache/pom.xml index 876103002b..42311d128a 100644 --- a/spring-boot-samples/spring-boot-sample-cache/pom.xml +++ b/spring-boot-samples/spring-boot-sample-cache/pom.xml @@ -41,7 +41,7 @@ cache-api --> - +