diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java index b79b502d1a8..680861092ee 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java @@ -61,7 +61,7 @@ import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping; /** * {@link EnableAutoConfiguration Auto-configuration} for common management * {@link Endpoint}s. - * + * * @author Dave Syer * @author Phillip Webb * @author Greg Turnquist diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java index 4cf63f1bd89..1c70ad1ef4d 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java @@ -47,15 +47,15 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; /** * {@link EnableAutoConfiguration Auto-configuration} for {@link HealthIndicator}s. - * + * * @author Christian Dupuis * @since 1.1.0 */ @Configuration @AutoConfigureBefore({ EndpointAutoConfiguration.class }) @AutoConfigureAfter({ DataSourceAutoConfiguration.class, MongoAutoConfiguration.class, - MongoDataAutoConfiguration.class, RedisAutoConfiguration.class, - RabbitAutoConfiguration.class }) + MongoDataAutoConfiguration.class, RedisAutoConfiguration.class, + RabbitAutoConfiguration.class }) public class HealthIndicatorAutoConfiguration { @Bean diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java index 016c5bded10..6f44146b89a 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java @@ -26,7 +26,7 @@ import org.springframework.util.Assert; /** * {@link Endpoint} to expose application health. - * + * * @author Dave Syer * @author Christian Dupuis */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/VanillaPublicMetrics.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/VanillaPublicMetrics.java index 38386cc665a..d18b74a5897 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/VanillaPublicMetrics.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/VanillaPublicMetrics.java @@ -33,7 +33,7 @@ import org.springframework.util.StringUtils; /** * Default implementation of {@link PublicMetrics} that exposes all metrics from a * {@link MetricReader} along with memory information. - * + * * @author Dave Syer * @author Christian Dupuis */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleDataSourceHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleDataSourceHealthIndicator.java index 181480c9ade..383ccf7d303 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleDataSourceHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleDataSourceHealthIndicator.java @@ -35,7 +35,8 @@ import org.springframework.util.StringUtils; * * @author Dave Syer */ -public class SimpleDataSourceHealthIndicator implements HealthIndicator> { +public class SimpleDataSourceHealthIndicator implements + HealthIndicator> { private DataSource dataSource; @@ -61,7 +62,8 @@ public class SimpleDataSourceHealthIndicator implements HealthIndicator { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisServer.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisServer.java index 2ca3732c14b..fd49226b849 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisServer.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisServer.java @@ -122,7 +122,7 @@ public class RedisServer implements TestRule { /** * Perform cleanup of the {@link #resource} field, which is guaranteed to be non null. - * + * * @throws Exception any exception thrown by this method will be logged and swallowed */ protected void cleanupResource() throws Exception { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/WebRequestTraceFilterTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/WebRequestTraceFilterTests.java index 24c0b05f351..efa1fafb11e 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/WebRequestTraceFilterTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/WebRequestTraceFilterTests.java @@ -27,7 +27,7 @@ import static org.junit.Assert.assertEquals; /** * Tests for {@link WebRequestTraceFilter}. - * + * * @author Dave Syer */ public class WebRequestTraceFilterTests { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java index f42940d0c23..185998629c8 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java @@ -114,7 +114,7 @@ public class BasicBatchConfigurer implements BatchConfigurer { } factory.setTransactionManager(getTransactionManager()); factory.afterPropertiesSet(); - return (JobRepository) factory.getObject(); + return factory.getObject(); } protected PlatformTransactionManager createTransactionManager() { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java index 6a23af9d656..348466fa361 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java @@ -37,7 +37,7 @@ import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguratio * Once in effect, the auto-configuration is the equivalent of importing the * {@link RepositoryRestMvcConfiguration}. *

- * + * * @author Rob Winch * @since 1.1.0 */ diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java index 64380ffeda5..1b8970cea5e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java @@ -28,7 +28,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.boot.autoconfigure.template.TemplateViewResolverConfigurer; import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -45,7 +44,7 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; /** * {@link EnableAutoConfiguration Auto-configuration} for FreeMarker. - * + * * @author Andy Wilkinson * @author Dave Syer * @since 1.1.0 @@ -67,12 +66,10 @@ public class FreeMarkerAutoConfiguration { if (this.properties.isCheckTemplateLocation()) { Resource resource = this.resourceLoader.getResource(this.properties .getTemplateLoaderPath()); - Assert.state( - resource.exists(), - "Cannot find template location: " - + resource - + " (please add some templates, check your FreeMarker configuration, or set " - + "spring.freemarker.checkTemplateLocation=false)"); + Assert.state(resource.exists(), "Cannot find template location: " + resource + + " (please add some templates, " + + "check your FreeMarker configuration, or set " + + "spring.freemarker.checkTemplateLocation=false)"); } } @@ -128,8 +125,7 @@ public class FreeMarkerAutoConfiguration { @ConditionalOnMissingBean(name = "freeMarkerViewResolver") public FreeMarkerViewResolver freeMarkerViewResolver() { FreeMarkerViewResolver resolver = new FreeMarkerViewResolver(); - new TemplateViewResolverConfigurer().configureTemplateViewResolver(resolver, - this.properties); + this.properties.applyToViewResolver(resolver); return resolver; } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java index f6628919856..77bcf1ac63a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -21,13 +21,13 @@ import java.util.Map; import org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; /** * {@link ConfigurationProperties} for configuring FreeMarker - * + * * @author Dave Syer * @author Andy Wilkinson - * * @since 1.1.0 */ @ConfigurationProperties(prefix = "spring.freemarker") @@ -62,4 +62,12 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties public void setTemplateLoaderPath(String templateLoaderPath) { this.templateLoaderPath = templateLoaderPath; } + + /** + * Apply the given properties to a {@link FreeMarkerViewResolver}. + * @param resolver the resolver to apply the properties to. + */ + public void applyToViewResolver(FreeMarkerViewResolver resolver) { + super.applyToViewResolver(resolver); + } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java index 082cf49b2fd..93ad581cd0b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateProperties.java index 3ac8c358957..669ed3bb85b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -22,6 +22,8 @@ import java.util.Map; import org.springframework.boot.context.properties.ConfigurationProperties; /** + * {@link ConfigurationProperties} for configuring Groovy templates. + * * @author Dave Syer * @since 1.1.0 */ diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateResolver.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateResolver.java index d1bfa0da6fb..d04c6b55069 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateResolver.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2012 the original author or authors. + * Copyright 2012-2014 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. @@ -18,38 +18,43 @@ package org.springframework.boot.autoconfigure.groovy.template; import groovy.text.markup.MarkupTemplateEngine; import groovy.text.markup.TemplateConfiguration; import groovy.text.markup.TemplateResolver; -import org.springframework.context.i18n.LocaleContextHolder; import java.io.IOException; import java.net.URL; +import org.springframework.context.i18n.LocaleContextHolder; + /** - * A custom {@link groovy.text.markup.TemplateResolver template resolver} which resolves templates using the locale - * found in the thread locale. This resolver ignores the template engine configuration locale. - * + * A custom {@link groovy.text.markup.TemplateResolver template resolver} which resolves + * templates using the locale found in the thread locale. This resolver ignores the + * template engine configuration locale. + * * @author Cédric Champeau * @since 1.1.0 */ - public class GroovyTemplateResolver implements TemplateResolver { - private ClassLoader templateClassLoader; + private ClassLoader templateClassLoader; - @Override - public void configure(final ClassLoader templateClassLoader, final TemplateConfiguration configuration) { - this.templateClassLoader = templateClassLoader; - } + @Override + public void configure(final ClassLoader templateClassLoader, + final TemplateConfiguration configuration) { + this.templateClassLoader = templateClassLoader; + } - @Override - public URL resolveTemplate(final String templatePath) throws IOException { - MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource.parse(templatePath); - URL resource = templateClassLoader.getResource(templateResource.withLocale(LocaleContextHolder.getLocale().toString().replace("-", "_")).toString()); - if (resource == null) { - // no resource found with the default locale, try without any locale - resource = templateClassLoader.getResource(templateResource.withLocale(null).toString()); - } - if (resource == null) { - throw new IOException("Unable to load template:" + templatePath); - } - return resource; - } + @Override + public URL resolveTemplate(final String templatePath) throws IOException { + MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource + .parse(templatePath); + URL resource = this.templateClassLoader.getResource(templateResource.withLocale( + LocaleContextHolder.getLocale().toString().replace("-", "_")).toString()); + if (resource == null) { + // no resource found with the default locale, try without any locale + resource = this.templateClassLoader.getResource(templateResource.withLocale( + null).toString()); + } + if (resource == null) { + throw new IOException("Unable to load template:" + templatePath); + } + return resource; + } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java index 75be23c1751..f4ed848585f 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java @@ -21,9 +21,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.integration.config.EnableIntegration; /** - * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration Auto-configuration} - * for Spring Integration. - * + * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration + * Auto-configuration} for Spring Integration. + * * @author Artem Bilan * @since 1.1 */ diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProvider.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProvider.java index 32f013a5db2..581315bfd44 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProvider.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProvider.java @@ -13,8 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.boot.autoconfigure.jdbc; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -22,7 +24,7 @@ import org.springframework.util.Assert; /** * Provides JDBC driver class name for given JDBC URL. - * + * * @author Maciej Walkowiak * @since 1.1.0 */ @@ -30,50 +32,39 @@ class DriverClassNameProvider { private static final String JDBC_URL_PREFIX = "jdbc"; - private static final Map driverMap = new HashMap() { - { - put("db2", "com.ibm.db2.jcc.DB2Driver"); - put("derby", "org.apache.derby.jdbc.EmbeddedDriver"); - put("h2", "org.h2.Driver"); - put("hsqldb", "org.hsqldb.jdbcDriver"); - put("sqlite", "org.sqlite.JDBC"); - put("mysql", "com.mysql.jdbc.Driver"); - put("mariadb", "org.mariadb.jdbc.Driver"); - put("google", "com.google.appengine.api.rdbms.AppEngineDriver"); - put("oracle", "oracle.jdbc.OracleDriver"); - put("postgresql", "org.postgresql.Driver"); - put("jtds", "net.sourceforge.jtds.jdbc.Driver"); - put("sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver"); - - } - }; + private static final Map DRIVERS; + static { + Map drivers = new HashMap(); + drivers.put("derby", "org.apache.derby.jdbc.EmbeddedDriver"); + drivers.put("h2", "org.h2.Driver"); + drivers.put("hsqldb", "org.hsqldb.jdbcDriver"); + drivers.put("sqlite", "org.sqlite.JDBC"); + drivers.put("mysql", "com.mysql.jdbc.Driver"); + drivers.put("mariadb", "org.mariadb.jdbc.Driver"); + drivers.put("google", "com.google.appengine.api.rdbms.AppEngineDriver"); + drivers.put("oracle", "oracle.jdbc.OracleDriver"); + drivers.put("postgresql", "org.postgresql.Driver"); + drivers.put("jtds", "net.sourceforge.jtds.jdbc.Driver"); + drivers.put("sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver"); + DRIVERS = Collections.unmodifiableMap(drivers); + } /** - * Used to find JDBC driver class name based on given JDBC URL - * + * Find a JDBC driver class name based on given JDBC URL * @param jdbcUrl JDBC URL * @return driver class name or null if not found */ String getDriverClassName(final String jdbcUrl) { - Assert.notNull(jdbcUrl, "JDBC URL cannot be null"); - - if (!jdbcUrl.startsWith(JDBC_URL_PREFIX)) { - throw new IllegalArgumentException("JDBC URL should start with '" - + JDBC_URL_PREFIX + "'"); - } - + Assert.notNull(jdbcUrl, "JdbcUrl must not be null"); + Assert.isTrue(jdbcUrl.startsWith(JDBC_URL_PREFIX), "JdbcUrl must start with '" + + JDBC_URL_PREFIX + "'"); String urlWithoutPrefix = jdbcUrl.substring(JDBC_URL_PREFIX.length()); - String result = null; - - for (Map.Entry driver : driverMap.entrySet()) { + for (Map.Entry driver : DRIVERS.entrySet()) { if (urlWithoutPrefix.startsWith(":" + driver.getKey() + ":")) { - result = driver.getValue(); - - break; + return driver.getValue(); } } - - return result; + return null; } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java index 3007965c586..f5cde4c5e72 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java @@ -33,7 +33,7 @@ import com.mongodb.MongoClientOptions; /** * {@link EnableAutoConfiguration Auto-configuration} for Mongo. - * + * * @author Dave Syer * @author Oliver Gierke * @author Phillip Webb diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilder.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilder.java index 9b0f793732a..bb14ef2d31e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilder.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilder.java @@ -71,8 +71,6 @@ public class EntityManagerFactoryBuilder { /** * An optional callback for new entity manager factory beans. - * - * @author Dave Syer */ public void setCallback(EntityManagerFactoryBeanCallback callback) { this.callback = callback; @@ -171,8 +169,6 @@ public class EntityManagerFactoryBuilder { /** * A callback for new entity manager factory beans created by a Builder. - * - * @author Dave Syer */ public static interface EntityManagerFactoryBeanCallback { 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 ce13fdd677a..fb0345f03a1 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 @@ -128,8 +128,8 @@ public class AuthenticationManagerConfiguration extends User user = AuthenticationManagerConfiguration.this.security.getUser(); if (user.isDefaultPassword()) { - logger.info("\n\nUsing default security password: " - + user.getPassword() + "\n\n"); + logger.info("\n\nUsing default security password: " + user.getPassword() + + "\n\n"); } this.defaultAuth = new AuthenticationManagerBuilder( diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractTemplateViewResolverProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractTemplateViewResolverProperties.java index bba7ca30941..d793b704549 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractTemplateViewResolverProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractTemplateViewResolverProperties.java @@ -17,12 +17,13 @@ package org.springframework.boot.autoconfigure.template; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.core.Ordered; import org.springframework.web.servlet.view.AbstractTemplateViewResolver; /** * Abstract base class for {@link ConfigurationProperties} for * {@link AbstractTemplateViewResolver view resolvers}. - * + * * @author Andy Wilkinson * @since 1.1.0 */ @@ -155,4 +156,25 @@ public abstract class AbstractTemplateViewResolverProperties { public void setExposeSpringMacroHelpers(boolean exposeSpringMacroHelpers) { this.exposeSpringMacroHelpers = exposeSpringMacroHelpers; } + + /** + * Apply the given properties to a {@link AbstractTemplateViewResolver}. + * @param resolver the resolver to apply the properties to. + */ + protected void applyToViewResolver(AbstractTemplateViewResolver resolver) { + resolver.setPrefix(getPrefix()); + resolver.setSuffix(getSuffix()); + resolver.setCache(isCache()); + resolver.setContentType(getContentType()); + resolver.setViewNames(getViewNames()); + resolver.setExposeRequestAttributes(isExposeRequestAttributes()); + resolver.setAllowRequestOverride(isAllowRequestOverride()); + resolver.setExposeSessionAttributes(isExposeSessionAttributes()); + resolver.setExposeSpringMacroHelpers(isExposeSpringMacroHelpers()); + resolver.setRequestContextAttribute(getRequestContextAttribute()); + // The resolver usually acts as a fallback resolver (e.g. like a + // InternalResourceViewResolver) so it needs to have low precedence + resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5); + } + } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateViewResolverConfigurer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateViewResolverConfigurer.java deleted file mode 100644 index 25128b4f7c7..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateViewResolverConfigurer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2012-2014 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.autoconfigure.template; - -import org.springframework.core.Ordered; -import org.springframework.web.servlet.view.AbstractTemplateViewResolver; - -/** - * Helper class for use by configuration classes that provide an - * {@link AbstractTemplateViewResolver} bean. - * - * @author Andy Wilkinson - */ -public class TemplateViewResolverConfigurer { - - /** - * Configures the {@code resolver} using the given {@code properties} and defaults. - * - * @param resolver The resolver to configure - * @param properties The properties to use to configure the resolver - */ - public void configureTemplateViewResolver(AbstractTemplateViewResolver resolver, - AbstractTemplateViewResolverProperties properties) { - - resolver.setPrefix(properties.getPrefix()); - resolver.setSuffix(properties.getSuffix()); - resolver.setCache(properties.isCache()); - resolver.setContentType(properties.getContentType()); - resolver.setViewNames(properties.getViewNames()); - resolver.setExposeRequestAttributes(properties.isExposeRequestAttributes()); - resolver.setAllowRequestOverride(properties.isAllowRequestOverride()); - resolver.setExposeSessionAttributes(properties.isExposeSessionAttributes()); - resolver.setExposeSpringMacroHelpers(properties.isExposeSpringMacroHelpers()); - resolver.setRequestContextAttribute(properties.getRequestContextAttribute()); - - // This resolver acts as a fallback resolver (e.g. like a - // InternalResourceViewResolver) so it needs to have low precedence - resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5); - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java index 2ee9a77a3aa..540279c3ee3 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java @@ -50,7 +50,7 @@ import org.thymeleaf.templateresolver.TemplateResolver; /** * {@link EnableAutoConfiguration Auto-configuration} for Thymeleaf. - * + * * @author Dave Syer * @author Andy Wilkinson */ diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java index bb4525a1388..af24278e979 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java @@ -31,7 +31,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.boot.autoconfigure.template.TemplateViewResolverConfigurer; import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -48,7 +47,7 @@ import org.springframework.web.servlet.view.velocity.VelocityViewResolver; /** * {@link EnableAutoConfiguration Auto-configuration} for Velocity. - * + * * @author Andy Wilkinson * @since 1.1.0 */ @@ -69,11 +68,9 @@ public class VelocityAutoConfiguration { if (this.properties.isCheckTemplateLocation()) { Resource resource = this.resourceLoader.getResource(this.properties .getResourceLoaderPath()); - Assert.state( - resource.exists(), - "Cannot find template location: " - + resource - + " (please add some templates, check your Velocity configuration, or set spring.velocity.checkTemplateLocation=false)"); + Assert.state(resource.exists(), "Cannot find template location: " + resource + + " (please add some templates, check your Velocity configuration, " + + "or set spring.velocity.checkTemplateLocation=false)"); } } @@ -88,6 +85,7 @@ public class VelocityAutoConfiguration { velocityProperties.putAll(this.properties.getProperties()); factory.setVelocityProperties(velocityProperties); } + } @Configuration @@ -127,12 +125,10 @@ public class VelocityAutoConfiguration { @ConditionalOnMissingBean(name = "velocityViewResolver") public VelocityViewResolver velocityViewResolver() { VelocityViewResolver resolver = new VelocityViewResolver(); - new TemplateViewResolverConfigurer().configureTemplateViewResolver(resolver, - this.properties); - resolver.setToolboxConfigLocation(this.properties.getToolboxConfigLocation()); - resolver.setDateToolAttribute(this.properties.getDateToolAttribute()); - resolver.setNumberToolAttribute(this.properties.getNumberToolAttribute()); + this.properties.applyToViewResolver(resolver); return resolver; } + } + } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityProperties.java index 1c9c0450cbd..cfb05572e55 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityProperties.java @@ -21,12 +21,12 @@ import java.util.Map; import org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.web.servlet.view.velocity.VelocityViewResolver; /** * {@link ConfigurationProperties} for configuring Velocity - * + * * @author Andy Wilkinson - * * @since 1.1.0 */ @ConfigurationProperties(prefix = "spring.velocity") @@ -91,4 +91,16 @@ public class VelocityProperties extends AbstractTemplateViewResolverProperties { public void setToolboxConfigLocation(String toolboxConfigLocation) { this.toolboxConfigLocation = toolboxConfigLocation; } + + /** + * Apply the given properties to a {@link VelocityViewResolver}. + * @param resolver the resolver to apply the properties to. + */ + public void applyToViewResolver(VelocityViewResolver resolver) { + super.applyToViewResolver(resolver); + resolver.setToolboxConfigLocation(getToolboxConfigLocation()); + resolver.setDateToolAttribute(getDateToolAttribute()); + resolver.setNumberToolAttribute(getNumberToolAttribute()); + } + } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProvider.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProvider.java index 79aa84de469..a16a6965da5 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProvider.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProvider.java @@ -24,7 +24,7 @@ import org.springframework.util.ClassUtils; /** * {@link TemplateAvailabilityProvider} that provides availability information for * Velocity view templates - * + * * @author Andy Wilkinson * @since 1.1.0 */ 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 12ae38c7af5..e25d4afc8b7 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 @@ -231,7 +231,7 @@ public class BatchAutoConfigurationTests { public JobRepository getJobRepository() throws Exception { if (this.jobRepository == null) { this.factory.afterPropertiesSet(); - this.jobRepository = (JobRepository) this.factory.getObject(); + this.jobRepository = this.factory.getObject(); } return this.jobRepository; } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java index db0168bfb96..ff3dc4d87e7 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java @@ -16,13 +16,12 @@ package org.springframework.boot.autoconfigure.integration; -import static org.junit.Assert.*; - import org.junit.Test; - import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.integration.support.channel.HeaderChannelRegistry; +import static org.junit.Assert.assertNotNull; + /** * @author Artem Bilan * @since 1.1 diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourcePropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourcePropertiesTests.java index 08ff2a68ff8..75ee78555fd 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourcePropertiesTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourcePropertiesTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.autoconfigure.jdbc; import org.junit.Test; @@ -6,7 +22,7 @@ import static org.junit.Assert.assertEquals; /** * Tests for {@link DataSourceProperties}. - * + * * @author Maciej Walkowiak */ public class DataSourcePropertiesTests { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProviderTest.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProviderTest.java deleted file mode 100644 index b7494b8b291..00000000000 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProviderTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012-2014 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.boot.autoconfigure.jdbc; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -/** - * Tests for {@link DriverClassNameProvider}. - * - * @author Maciej Walkowiak - */ -public class DriverClassNameProviderTest { - private DriverClassNameProvider driverClassNameProvider = new DriverClassNameProvider(); - - @Test - public void testGettingClassNameForKnownDatabase() { - String driverClassName = driverClassNameProvider.getDriverClassName("jdbc:postgresql://hostname/dbname"); - - assertEquals("org.postgresql.Driver", driverClassName); - } - - @Test - public void testReturnsNullForUnknownDatabase() { - String driverClassName = driverClassNameProvider.getDriverClassName("jdbc:unknowndb://hostname/dbname"); - - assertNull(driverClassName); - } - - @Test(expected = IllegalArgumentException.class) - public void testFailureOnNullJdbcUrl() { - driverClassNameProvider.getDriverClassName(null); - } - - @Test(expected = IllegalArgumentException.class) - public void testFailureOnMalformedJdbcUrl() { - driverClassNameProvider.getDriverClassName("malformed:url"); - } -} \ No newline at end of file diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProviderTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProviderTests.java new file mode 100644 index 00000000000..913315b4903 --- /dev/null +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DriverClassNameProviderTests.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012-2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.autoconfigure.jdbc; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +/** + * Tests for {@link DriverClassNameProvider}. + * + * @author Maciej Walkowiak + */ +public class DriverClassNameProviderTests { + + private DriverClassNameProvider provider = new DriverClassNameProvider(); + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void classNameForKnownDatabase() { + String driverClassName = this.provider + .getDriverClassName("jdbc:postgresql://hostname/dbname"); + assertEquals("org.postgresql.Driver", driverClassName); + } + + @Test + public void nullForUnknownDatabase() { + String driverClassName = this.provider + .getDriverClassName("jdbc:unknowndb://hostname/dbname"); + assertNull(driverClassName); + } + + @Test + public void failureOnNullJdbcUrl() { + this.thrown.expect(IllegalArgumentException.class); + this.thrown.expectMessage("JdbcUrl must not be null"); + this.provider.getDriverClassName(null); + } + + @Test + public void failureOnMalformedJdbcUrl() { + this.thrown.expect(IllegalArgumentException.class); + this.thrown.expectMessage("JdbcUrl must start with"); + this.provider.getDriverClassName("malformed:url"); + } + +} diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderTests.java index 1623978427d..d9c5b1ccf10 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -29,6 +29,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** + * Tests for {@link EntityManagerFactoryBuilder}. + * * @author Dave Syer */ public class EntityManagerFactoryBuilderTests { 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 c4682beb05d..f71e6e8cd01 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 @@ -47,7 +47,7 @@ import static org.junit.Assert.assertThat; /** * Tests for {@link VelocityAutoConfiguration}. - * + * * @author Andy Wilkinson */ public class VelocityAutoConfigurationTests { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProviderTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProviderTests.java index 1804a6c9872..22a456ba0a0 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProviderTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProviderTests.java @@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue; /** * Tests for {@link VelocityTemplateAvailabilityProvider}. - * + * * @author Andy Wilkinson */ public class VelocityTemplateAvailabilityProviderTests { diff --git a/spring-boot-cli/samples/beans.groovy b/spring-boot-cli/samples/beans.groovy index 7a8661dc228..4fbf427876b 100644 --- a/spring-boot-cli/samples/beans.groovy +++ b/spring-boot-cli/samples/beans.groovy @@ -1,7 +1,9 @@ @RestController class Application { + @Autowired String foo + @RequestMapping("/") String home() { "Hello ${foo}!" @@ -10,4 +12,4 @@ class Application { beans { foo String, "World" -} \ No newline at end of file +} diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java index e7d59dcce7a..a60d181b5c4 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java @@ -119,6 +119,7 @@ public class Shell { private void attachSignalHandler() { SignalUtils.attachSignalHandler(new Runnable() { + @Override public void run() { handleSigInt(); } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/AnnotatedNodeASTTransformation.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/AnnotatedNodeASTTransformation.java index 37a8a2e35ef..bf3e4629342 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/AnnotatedNodeASTTransformation.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/AnnotatedNodeASTTransformation.java @@ -34,7 +34,7 @@ import org.codehaus.groovy.transform.ASTTransformation; /** * A base class for {@link ASTTransformation AST transformations} that are solely * interested in {@link AnnotatedNode AnnotatedNodes}. - * + * * @author Andy Wilkinson * @since 1.1.0 */ diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyAutoConfigurationTransformation.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyAutoConfigurationTransformation.java index 0be0e86ef3f..71c57488d9d 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyAutoConfigurationTransformation.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyAutoConfigurationTransformation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -28,7 +28,7 @@ import org.codehaus.groovy.transform.ASTTransformation; * {@link ASTTransformation} to apply * {@link CompilerAutoConfiguration#applyDependencies(DependencyCustomizer) dependency * auto-configuration}. - * + * * @author Phillip Webb * @author Dave Syer * @author Andy Wilkinson diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java index 401d0a1ff89..188ad47141a 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -32,7 +32,7 @@ import org.springframework.boot.cli.compiler.dependencies.ArtifactCoordinatesRes *

* This class provides a fluent API for conditionally adding dependencies. For example: * {@code dependencies.ifMissing("com.corp.SomeClass").add(module)}. - * + * * @author Phillip Webb * @author Andy Wilkinson */ diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyResolutionContext.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyResolutionContext.java index aa6b4950215..ed66789b002 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyResolutionContext.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyResolutionContext.java @@ -26,6 +26,8 @@ import org.springframework.boot.cli.compiler.grape.ManagedDependenciesFactory; import org.springframework.boot.dependency.tools.ManagedDependencies; /** + * Context used when resolving dependencies. + * * @author Andy Wilkinson * @since 1.1.0 */ diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrabMetadataTransformation.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrabMetadataTransformation.java index d7bf66b2a66..2b976a12b04 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrabMetadataTransformation.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrabMetadataTransformation.java @@ -45,7 +45,7 @@ import org.springframework.boot.groovy.GrabMetadata; /** * {@link ASTTransformation} for processing {@link GrabMetadata @GrabMetadata} - * + * * @author Andy Wilkinson * @since 1.1.0 */ @@ -78,7 +78,6 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation { private void processGrabMetadataAnnotation(AnnotationNode annotationNode) { Expression valueExpression = annotationNode.getMember("value"); - List> metadataDependencies = createDependencyMaps(valueExpression); updateArtifactCoordinatesResolver(metadataDependencies); } @@ -86,32 +85,7 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation { private List> createDependencyMaps(Expression valueExpression) { Map dependency = null; - List constantExpressions = new ArrayList(); - - if (valueExpression instanceof ListExpression) { - ListExpression listExpression = (ListExpression) valueExpression; - for (Expression expression : listExpression.getExpressions()) { - if (expression instanceof ConstantExpression - && ((ConstantExpression) expression).getValue() instanceof String) { - constantExpressions.add((ConstantExpression) expression); - } - else { - reportError( - "Each entry in the array must be an inline string constant", - expression); - } - } - } - else if (valueExpression instanceof ConstantExpression - && ((ConstantExpression) valueExpression).getValue() instanceof String) { - constantExpressions = Arrays.asList((ConstantExpression) valueExpression); - } - else { - reportError( - "@GrabMetadata requires an inline constant that is a string or a string array", - valueExpression); - } - + List constantExpressions = getConstantExpressions(valueExpression); List> dependencies = new ArrayList>( constantExpressions.size()); @@ -125,7 +99,6 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation { dependency.put("module", components[1]); dependency.put("version", components[2]); dependency.put("type", "properties"); - dependencies.add(dependency); } else { @@ -137,6 +110,36 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation { return dependencies; } + private List getConstantExpressions(Expression valueExpression) { + if (valueExpression instanceof ListExpression) { + return getConstantExpressions((ListExpression) valueExpression); + } + + if (valueExpression instanceof ConstantExpression + && ((ConstantExpression) valueExpression).getValue() instanceof String) { + return Arrays.asList((ConstantExpression) valueExpression); + } + + reportError("@GrabMetadata requires an inline constant that is a " + + "string or a string array", valueExpression); + return Collections.emptyList(); + } + + private List getConstantExpressions(ListExpression valueExpression) { + List expressions = new ArrayList(); + for (Expression expression : valueExpression.getExpressions()) { + if (expression instanceof ConstantExpression + && ((ConstantExpression) expression).getValue() instanceof String) { + expressions.add((ConstantExpression) expression); + } + else { + reportError("Each entry in the array must be an " + + "inline string constant", expression); + } + } + return expressions; + } + private void handleMalformedDependency(Expression expression) { Message message = createSyntaxErrorMessage( "The string must be of the form \"group:module:version\"\n", expression); @@ -154,7 +157,7 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation { managedDependencies.add(new PropertiesFileManagedDependencies(uri.toURL() .openStream())); } - catch (IOException e) { + catch (IOException ex) { throw new IllegalStateException("Failed to parse '" + uris[0] + "'. Is it a valid properties file?"); } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java index 2be52d1f427..190dcbaa157 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java @@ -56,13 +56,13 @@ import org.springframework.boot.cli.util.ResourceUtils; *

  • {@link CompilerAutoConfiguration} strategies will be read from * META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration * (per the standard java {@link ServiceLoader} contract) and applied during compilation
  • - * + * *
  • Multiple classes can be returned if the Groovy source defines more than one Class
  • - * + * *
  • Generated class files can also be loaded using * {@link ClassLoader#getResource(String)}
  • * - * + * * @author Phillip Webb * @author Dave Syer * @author Andy Wilkinson @@ -167,7 +167,7 @@ public class GroovyCompiler { * @throws IOException */ public Class[] compile(String... sources) throws CompilationFailedException, - IOException { + IOException { this.loader.clearCache(); List> classes = new ArrayList>(); @@ -287,9 +287,9 @@ public class GroovyCompiler { classNode); } autoConfiguration - .apply(GroovyCompiler.this.loader, - GroovyCompiler.this.configuration, context, source, - classNode); + .apply(GroovyCompiler.this.loader, + GroovyCompiler.this.configuration, context, source, + classNode); } } importCustomizer.call(source, context, classNode); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java index 10046e63d56..78a548346b6 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -31,12 +31,12 @@ import org.codehaus.groovy.transform.ASTTransformation; /** * {@link ASTTransformation} to resolve {@link Grab} artifact coordinates. - * + * * @author Andy Wilkinson * @author Phillip Webb */ public class ResolveDependencyCoordinatesTransformation extends -AnnotatedNodeASTTransformation { + AnnotatedNodeASTTransformation { private static final Set GRAB_ANNOTATION_NAMES = Collections .unmodifiableSet(new HashSet(Arrays.asList(Grab.class.getName(), diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java index 963a59a4666..bb2e4032686 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -30,7 +30,7 @@ import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration; /** * {@link CompilerAutoConfiguration} for Spring. - * + * * @author Dave Syer * @author Phillip Webb */ @@ -39,7 +39,7 @@ public class SpringBootCompilerAutoConfiguration extends CompilerAutoConfigurati @Override public void applyDependencies(DependencyCustomizer dependencies) { dependencies.ifAnyMissingClasses("org.springframework.boot.SpringApplication") - .add("spring-boot-starter"); + .add("spring-boot-starter"); } @Override diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java index 256f407041b..b5d9ac0dbe5 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java @@ -24,7 +24,7 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer; /** * {@link CompilerAutoConfiguration} for Spring Integration. - * + * * @author Dave Syer * @author Artem Bilan */ diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ManagedDependenciesArtifactCoordinatesResolver.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ManagedDependenciesArtifactCoordinatesResolver.java index d4dc88ae637..c88fa234aa3 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ManagedDependenciesArtifactCoordinatesResolver.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ManagedDependenciesArtifactCoordinatesResolver.java @@ -22,7 +22,7 @@ import org.springframework.boot.dependency.tools.VersionManagedDependencies; /** * {@link ArtifactCoordinatesResolver} backed by {@link ManagedDependencies}. - * + * * @author Phillip Webb */ public class ManagedDependenciesArtifactCoordinatesResolver implements diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java index 68d3dadab7a..ebca33f4b5c 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java @@ -49,7 +49,7 @@ import org.springframework.boot.cli.compiler.DependencyResolutionContext; * A {@link GrapeEngine} implementation that uses Aether, the dependency resolution system used by * Maven. - * + * * @author Andy Wilkinson * @author Phillip Webb */ diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineFactory.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineFactory.java index 9f5029ae39c..411a9da3c53 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineFactory.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineFactory.java @@ -39,7 +39,7 @@ import org.springframework.boot.cli.compiler.DependencyResolutionContext; /** * Utility class to create a pre-configured {@link AetherGrapeEngine}. - * + * * @author Andy Wilkinson */ public abstract class AetherGrapeEngineFactory { @@ -86,7 +86,7 @@ public abstract class AetherGrapeEngineFactory { for (RepositoryConfiguration repositoryConfiguration : repositoryConfigurations) { RemoteRepository.Builder builder = new RemoteRepository.Builder( repositoryConfiguration.getName(), "default", repositoryConfiguration - .getUri().toASCIIString()); + .getUri().toASCIIString()); if (!repositoryConfiguration.getSnapshotsEnabled()) { builder.setSnapshotPolicy(new RepositoryPolicy(false, diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/ManagedDependenciesFactory.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/ManagedDependenciesFactory.java index b09642977d1..e3742ad47d7 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/ManagedDependenciesFactory.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/ManagedDependenciesFactory.java @@ -30,7 +30,7 @@ import org.springframework.boot.dependency.tools.VersionManagedDependencies; /** * Factory to create Maven {@link Dependency} objects from Boot * {@link PomManagedDependencies}. - * + * * @author Phillip Webb */ public class ManagedDependenciesFactory { diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/groovy/GrabMetadata.java b/spring-boot-cli/src/main/java/org/springframework/boot/groovy/GrabMetadata.java index 7427e42277e..39f39e90c11 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/groovy/GrabMetadata.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/groovy/GrabMetadata.java @@ -24,12 +24,12 @@ import java.lang.annotation.Target; /** * Used to provide an alternative source of dependency metadata that is used to deduce * groups and versions when processing {@code @Grab} dependencies. - * + * * @author Andy Wilkinson * @since 1.1.0 */ @Target({ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, - ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE }) + ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE }) @Retention(RetentionPolicy.SOURCE) public @interface GrabMetadata { @@ -39,4 +39,5 @@ public @interface GrabMetadata { * default metadata. */ String[] value(); + } diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java index e73f4cdc3bd..0aef4c01a0a 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java @@ -32,7 +32,7 @@ import static org.junit.Assert.fail; /** * Integration tests for {@link GrabCommand} - * + * * @author Andy Wilkinson * @author Dave Syer */ diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformationTests.java index cd349e2544a..33ae85573cd 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformationTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -50,7 +50,7 @@ import static org.mockito.Mockito.when; /** * Tests for {@link ResolveDependencyCoordinatesTransformation} - * + * * @author Andy Wilkinson */ public final class ResolveDependencyCoordinatesTransformationTests { diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java index 537175befde..d0bb151da34 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java @@ -30,7 +30,7 @@ import static org.junit.Assert.assertEquals; /** * Tests for {@link AetherGrapeEngine}. - * + * * @author Andy Wilkinson */ public class AetherGrapeEngineTests { @@ -40,7 +40,7 @@ public class AetherGrapeEngineTests { private final AetherGrapeEngine grapeEngine = AetherGrapeEngineFactory.create( this.groovyClassLoader, Arrays.asList(new RepositoryConfiguration("central", URI.create("http://repo1.maven.org/maven2"), false)), - new DependencyResolutionContext()); + new DependencyResolutionContext()); @Test public void dependencyResolution() { diff --git a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc index d830ca8dc66..2b58543f463 100644 --- a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc +++ b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc @@ -232,6 +232,8 @@ example: } ---- + + [[build-tool-plugins-gradle-custom-version-management]] ==== Custom version management If is possible to customize the versions used by the `ResolutionStrategy` if you need @@ -257,6 +259,8 @@ the above example `mycorp-versions.properties` file might contain the following: The properties file takes precedence over Spring Boot's defaults, and can be used to override version numbers if necessary. + + [[build-tool-plugins-gradle-packaging]] === Packaging executable jar and war files Once the `spring-boot` plugin has been applied to your project it will automatically diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index eb152c0aef3..362cd4ea4be 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -788,12 +788,10 @@ added. (defaults are both empty, but accessible for external configuration via `spring.view.prefix` and `spring.view.suffix`). It can be overridden by providing a bean of the same type. - * A `BeanNameViewResolver` with id ``beanNameViewResolver''. This is a useful member of the view resolver chain and will pick up any beans with the same name as the `View` being resolved. It can be overridden by providing a bean of the same type, but it's unlikely you will need to do that. - * A `ContentNegotiatingViewResolver` with id ``viewResolver'' is only added if there *are* actually beans of type `View` present. This is a ``master'' resolver, delegating to all the others and attempting to find a match to the ``Accept'' HTTP header sent by the @@ -802,28 +800,23 @@ added. that you might like to study to learn more, and also look at the source code for detail. You can switch off the auto-configured `ContentNegotiatingViewResolver` by defining a bean named ``viewResolver''. - * If you use Thymeleaf you will also have a `ThymeleafViewResolver` with id ``thymeleafViewResolver''. It looks for resources by surrounding the view name with a prefix and suffix (externalized to `spring.thymeleaf.prefix` and `spring.thymeleaf.suffix`, defaults ``classpath:/templates/'' and ``.html'' respectively). It can be overridden by providing a bean of the same name. - * If you use FreeMarker you will also have a `FreeMarkerViewResolver` with id ``freeMarkerViewResolver''. It looks for resources in a loader path (externalized to `spring.freemarker.templateLoaderPath`, default ``classpath:/templates/'') by surrounding the view name with a prefix and suffix (externalized to `spring.freemarker.prefix` - and `spring.freemarker.suffix`, with empty and ``.ftl'' defaults respectively). It can be overriden - by providing a bean of the same name. - + and `spring.freemarker.suffix`, with empty and ``.ftl'' defaults respectively). It can + be overridden by providing a bean of the same name. * If you use Groovy templates (actually if groovy-templates is on your classpath) you will - also have a `Groovy TemplateViewResolver` with id - ``groovyTemplateViewResolver''. It looks for resources in a loader path by - surrounding the view name with a prefix and suffix (externalized to - `spring.groovy.template.prefix` and `spring.groovy.template.suffix`, defaults - ``classpath:/templates/'' and ``.tpl'' respectively). It can be overriden by providing a bean of - the same name. - + also have a `Groovy TemplateViewResolver` with id ``groovyTemplateViewResolver''. It + looks for resources in a loader path by surrounding the view name with a prefix and + suffix (externalized to `spring.groovy.template.prefix` and + `spring.groovy.template.suffix`, defaults ``classpath:/templates/'' and ``.tpl'' + respectively). It can be overriden by providing a bean of the same name. * If you use Velocity you will also have a `VelocityViewResolver` with id ``velocityViewResolver''. It looks for resources in a loader path (externalized to `spring.velocity.resourceLoaderPath`, default ``classpath:/templates/'') by surrounding the view name with a prefix and suffix @@ -831,7 +824,7 @@ added. defaults respectively). It can be overridden by providing a bean of the same name. Check out {sc-spring-boot-autoconfigure}/web/WebMvcAutoConfiguration.{sc-ext}[`WebMvcAutoConfiguration`], -{sc-spring-boot-autoconfigure}/thymeleaf/ThymeleafAutoConfiguration.{sc-ext}[`ThymeleafAutoConfiguration`], +{sc-spring-boot-autoconfigure}/thymeleaf/ThymeleafAutoConfiguration.{sc-ext}[`ThymeleafAutoConfiguration`], {sc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{sc-ext}[`FreeMarkerAutoConfiguration`], {sc-spring-boot-autoconfigure}/groovy/template/GroovyTemplateAutoConfiguration.{sc-ext}[`GroovyTemplateAutoConfiguration`] and {sc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{sc-ext}[`VelocityAutoConfiguration`] @@ -1400,6 +1393,7 @@ If you are using Thymeleaf, then set `spring.thymeleaf.cache` to `false`. See for other Thymeleaf customization options. + [[howto-reload-freemarker-content]] === Reload FreeMarker templates without restarting the container If you are using FreeMarker, then set `spring.freemarker.cache` to `false`. See @@ -1407,6 +1401,7 @@ If you are using FreeMarker, then set `spring.freemarker.cache` to `false`. See for other FreeMarker customization options. + [[howto-reload-groovy-template-content]] === Reload Groovy templates without restarting the container If you are using Groovy templates, then set `spring.groovy.template.cache` to `false`. See @@ -1414,6 +1409,7 @@ If you are using Groovy templates, then set `spring.groovy.template.cache` to `f for other Groovy customization options. + [[howto-reload-velocity-content]] === Reload Velocity templates without restarting the container If you are using Velocity, then set `spring.velocity.cache` to `false`. See @@ -1421,6 +1417,7 @@ If you are using Velocity, then set `spring.velocity.cache` to `false`. See for other Velocity customization options. + [[howto-reload-java-classes-without-restarting]] === Reload Java classes without restarting the container Modern IDEs (Eclipse, IDEA, etc.) all support hot swapping of bytecode, so if you make a 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 1be5a62d947..81811711b80 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -906,16 +906,16 @@ and it will be silently ignored by most build tools if you generate a jar. [[boot-features-spring-mvc-template-engines]] ==== Template engines -As well as REST web services, you can also use Spring MVC to serve dynamic HTML content. Spring -MVC supports a variety of templating technologies including Velocity, FreeMarker and JSPs. Many -other templating engines also ship their own Spring MVC integrations. +As well as REST web services, you can also use Spring MVC to serve dynamic HTML content. +Spring MVC supports a variety of templating technologies including Velocity, FreeMarker +and JSPs. Many other templating engines also ship their own Spring MVC integrations. Spring Boot includes auto-configuration support for the following templating engines: - - http://freemarker.org/docs/[FreeMarker] - - http://beta.groovy-lang.org/docs/groovy-2.3.0/html/documentation/markup-template-engine.html[Groovy] - - http://www.thymeleaf.org[Thymeleaf] - - http://velocity.apache.org[Velocity] + * http://freemarker.org/docs/[FreeMarker] + * http://beta.groovy-lang.org/docs/groovy-2.3.0/html/documentation/markup-template-engine.html[Groovy] + * http://www.thymeleaf.org[Thymeleaf] + * http://velocity.apache.org[Velocity] When you're using one of these templating engines with the default configuration, your templates will be picked up automatically from `src/main/resources/templates`. @@ -1131,8 +1131,8 @@ The basic features you get out of the box in a web application are: on by default. All of the above can be switched on and off or modified using external properties -(`security.*`). To override the access rules without changing any other autoconfigured -features add a `@Bean` of type `WebConfigurerAdapter` with +(`security.*`). To override the access rules without changing any other autoconfigured +features add a `@Bean` of type `WebConfigurerAdapter` with `@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)`. If the Actuator is also in use, you will find: @@ -1142,10 +1142,10 @@ If the Actuator is also in use, you will find: * The default user will have the "ADMIN" role as well as the "USER" role. The Actuator security features can be modified using external properties -(`management.security.*`). To override the application access rules +(`management.security.*`). To override the application access rules add a `@Bean` of type `WebConfigurerAdapter` and use `@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)` if you _don't_ want to override -the actuator access rules, or `@Order(ManagementServerProperties.ACCESS_OVERRIDE_ORDER)` +the actuator access rules, or `@Order(ManagementServerProperties.ACCESS_OVERRIDE_ORDER)` if you _do_ want to override the actuator access rules. diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/test/java/sample/actuator/log4j/SampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator-log4j/src/test/java/sample/actuator/log4j/SampleActuatorApplicationTests.java index 13bc45706d8..4ff09437d90 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/test/java/sample/actuator/log4j/SampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator-log4j/src/test/java/sample/actuator/log4j/SampleActuatorApplicationTests.java @@ -22,8 +22,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.IntegrationTest; -import org.springframework.boot.test.TestRestTemplate; import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.boot.test.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java index c81c2a27f77..02701b46212 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java @@ -67,6 +67,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests { ResponseEntity entity = new TestRestTemplate().getForEntity( "http://localhost:" + this.port + "/admin/health", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); - assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\"")); + assertTrue("Wrong body: " + entity.getBody(), + entity.getBody().contains("\"status\":\"ok\"")); } } diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementAddressActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementAddressActuatorApplicationTests.java index 43e1f63f4b4..848b95ffc39 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementAddressActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementAddressActuatorApplicationTests.java @@ -72,7 +72,8 @@ public class ManagementAddressActuatorApplicationTests { "http://localhost:" + this.managementPort + "/admin/health", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); - assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\"")); + assertTrue("Wrong body: " + entity.getBody(), + entity.getBody().contains("\"status\":\"ok\"")); } } diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java index 0fec046a4d8..e959ddc85e7 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java @@ -81,7 +81,8 @@ public class ManagementPortSampleActuatorApplicationTests { ResponseEntity entity = new TestRestTemplate().getForEntity( "http://localhost:" + this.managementPort + "/health", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); - assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\"")); + assertTrue("Wrong body: " + entity.getBody(), + entity.getBody().contains("\"status\":\"ok\"")); } @Test diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java index 32ba32ffbe9..a662172a97f 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java @@ -130,7 +130,8 @@ public class SampleActuatorApplicationTests { ResponseEntity entity = new TestRestTemplate().getForEntity( "http://localhost:" + this.port + "/health", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); - assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\"")); + assertTrue("Wrong body: " + entity.getBody(), + entity.getBody().contains("\"status\":\"ok\"")); } @Test diff --git a/spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java b/spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java index 197d8eed51b..e423aef7abc 100644 --- a/spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java @@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue; /** * Tests for {@link SampleMongoApplication}. - * + * * @author Dave Syer */ public class SampleMongoApplicationTests { diff --git a/spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/SampleFlywayApplication.java b/spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/SampleFlywayApplication.java index 71bb8c9e744..4e027203efa 100644 --- a/spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/SampleFlywayApplication.java +++ b/spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/SampleFlywayApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -39,7 +39,7 @@ public class SampleFlywayApplication implements CommandLineRunner { @Override public void run(String... args) throws Exception { - System.err.println(repository.findAll()); + System.err.println(this.repository.findAll()); } public static void main(String[] args) throws Exception { @@ -61,7 +61,7 @@ class Person { private String lastName; public String getFirstName() { - return firstName; + return this.firstName; } public void setFirstName(String firstName) { @@ -69,7 +69,7 @@ class Person { } public String getLastName() { - return lastName; + return this.lastName; } public void setLastName(String lastname) { @@ -78,7 +78,7 @@ class Person { @Override public String toString() { - return "Person [firstName=" + firstName + ", lastName=" + lastName + return "Person [firstName=" + this.firstName + ", lastName=" + this.lastName + "]"; } } diff --git a/spring-boot-samples/spring-boot-sample-flyway/src/test/java/sample/flyway/SampleFlywayApplicationTests.java b/spring-boot-samples/spring-boot-sample-flyway/src/test/java/sample/flyway/SampleFlywayApplicationTests.java index 943e12eff67..6727479ccd2 100644 --- a/spring-boot-samples/spring-boot-sample-flyway/src/test/java/sample/flyway/SampleFlywayApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-flyway/src/test/java/sample/flyway/SampleFlywayApplicationTests.java @@ -16,8 +16,6 @@ package sample.flyway; -import static org.junit.Assert.assertEquals; - import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -25,16 +23,19 @@ import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.junit.Assert.assertEquals; + @RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes=SampleFlywayApplication.class) +@SpringApplicationConfiguration(classes = SampleFlywayApplication.class) public class SampleFlywayApplicationTests { - + @Autowired private JdbcTemplate template; - + @Test public void testDefaultSettings() throws Exception { - assertEquals(new Integer(1), template.queryForObject("SELECT COUNT(*) from PERSON", Integer.class)); + assertEquals(new Integer(1), this.template.queryForObject( + "SELECT COUNT(*) from PERSON", Integer.class)); } } diff --git a/spring-boot-samples/spring-boot-sample-liquibase/src/main/java/sample/liquibase/SampleLiquibaseApplication.java b/spring-boot-samples/spring-boot-sample-liquibase/src/main/java/sample/liquibase/SampleLiquibaseApplication.java index 7fc1fd02644..155021359c2 100644 --- a/spring-boot-samples/spring-boot-sample-liquibase/src/main/java/sample/liquibase/SampleLiquibaseApplication.java +++ b/spring-boot-samples/spring-boot-sample-liquibase/src/main/java/sample/liquibase/SampleLiquibaseApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -29,4 +29,5 @@ public class SampleLiquibaseApplication { public static void main(String[] args) throws Exception { SpringApplication.run(SampleLiquibaseApplication.class, args); } + } diff --git a/spring-boot-samples/spring-boot-sample-liquibase/src/test/java/sample/liquibase/SampleLiquibaseApplicationTests.java b/spring-boot-samples/spring-boot-sample-liquibase/src/test/java/sample/liquibase/SampleLiquibaseApplicationTests.java index f6337dc0a5f..390e7297807 100644 --- a/spring-boot-samples/spring-boot-sample-liquibase/src/test/java/sample/liquibase/SampleLiquibaseApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-liquibase/src/test/java/sample/liquibase/SampleLiquibaseApplicationTests.java @@ -41,14 +41,20 @@ public class SampleLiquibaseApplicationTests { } } String output = this.outputCapture.toString(); - assertTrue("Wrong output: " + output, - output.contains("Successfully acquired change log lock") && - output.contains("Creating database history table with name: PUBLIC.DATABASECHANGELOG") && - output.contains("Table person created") && - output.contains("ChangeSet classpath:/db/changelog/db.changelog-master.yaml::1::marceloverdijk ran successfully") && - output.contains("New row inserted into person") && - output.contains("ChangeSet classpath:/db/changelog/db.changelog-master.yaml::2::marceloverdijk ran successfully") && - output.contains("Successfully released change log lock")); + assertTrue( + "Wrong output: " + output, + output.contains("Successfully acquired change log lock") + && output.contains("Creating database history " + + "table with name: PUBLIC.DATABASECHANGELOG") + && output.contains("Table person created") + && output.contains("ChangeSet classpath:/db/" + + "changelog/db.changelog-master.yaml::1::" + + "marceloverdijk ran successfully") + && output.contains("New row inserted into person") + && output.contains("ChangeSet classpath:/db/changelog/" + + "db.changelog-master.yaml::2::" + + "marceloverdijk ran successfully") + && output.contains("Successfully released change log lock")); } private boolean serverNotRunning(IllegalStateException ex) { diff --git a/spring-boot-samples/spring-boot-sample-web-freemarker/src/test/java/sample/freemarker/SampleWebFreeMarkerApplicationTests.java b/spring-boot-samples/spring-boot-sample-web-freemarker/src/test/java/sample/freemarker/SampleWebFreeMarkerApplicationTests.java index d27f2366e09..6f30c90ffac 100644 --- a/spring-boot-samples/spring-boot-sample-web-freemarker/src/test/java/sample/freemarker/SampleWebFreeMarkerApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-web-freemarker/src/test/java/sample/freemarker/SampleWebFreeMarkerApplicationTests.java @@ -39,7 +39,7 @@ import static org.junit.Assert.assertTrue; /** * Basic integration tests for FreeMarker application. - * + * * @author Phillip Webb * @author Andy Wilkinson */ @@ -69,8 +69,8 @@ public class SampleWebFreeMarkerApplicationTests { HttpEntity requestEntity = new HttpEntity(headers); ResponseEntity responseEntity = new TestRestTemplate().exchange( - "http://localhost:" +port+ "/does-not-exist", HttpMethod.GET, requestEntity, - String.class); + "http://localhost:" + port + "/does-not-exist", HttpMethod.GET, + requestEntity, String.class); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); assertTrue("Wrong body:\n" + responseEntity.getBody(), responseEntity.getBody() diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/InMemoryMessageRespository.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/InMemoryMessageRespository.java index 76f97d53113..c0433f0d2ad 100644 --- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/InMemoryMessageRespository.java +++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/InMemoryMessageRespository.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -20,9 +20,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLong; -/** - * @author Dave Syer - */ public class InMemoryMessageRespository implements MessageRepository { private static AtomicLong counter = new AtomicLong(); diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/Message.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/Message.java index 11edb9aaef9..9eacad874d5 100644 --- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/Message.java +++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/Message.java @@ -1,14 +1,17 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2014 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. You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sample.ui; @@ -17,9 +20,6 @@ import java.util.Date; import org.hibernate.validator.constraints.NotEmpty; -/** - * @author Rob Winch - */ public class Message { private Long id; diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/MessageRepository.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/MessageRepository.java index 6bfd8199374..eff57222743 100644 --- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/MessageRepository.java +++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/MessageRepository.java @@ -1,21 +1,21 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2014 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. You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package sample.ui; -/** - * @author Rob Winch - */ public interface MessageRepository { Iterable findAll(); diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/SampleGroovyTemplateApplication.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/SampleGroovyTemplateApplication.java index f6cc1d87561..45daa1b6eb6 100644 --- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/SampleGroovyTemplateApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/SampleGroovyTemplateApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/mvc/MessageController.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/mvc/MessageController.java index a97268ad8b5..8ff7cc5e68a 100644 --- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/mvc/MessageController.java +++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/ui/mvc/MessageController.java @@ -1,16 +1,18 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2014 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. You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ - package sample.ui.mvc; import java.util.HashMap; @@ -33,9 +35,6 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes; import sample.ui.Message; import sample.ui.MessageRepository; -/** - * @author Rob Winch - */ @Controller @RequestMapping("/") public class MessageController { @@ -81,7 +80,7 @@ public class MessageController { for (FieldError error : result.getFieldErrors()) { map.put(error.getField(), error); } - return map ; + return map; } @RequestMapping("foo") diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/ui/MessageControllerWebTests.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/ui/MessageControllerWebTests.java index 9190e7daf0e..9d9ac3df245 100755 --- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/ui/MessageControllerWebTests.java +++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/ui/MessageControllerWebTests.java @@ -16,13 +16,6 @@ package sample.ui; -import static org.hamcrest.Matchers.containsString; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import java.util.regex.Pattern; import org.hamcrest.Description; @@ -39,6 +32,13 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import static org.hamcrest.Matchers.containsString; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + /** * A Basic Spring MVC Test for the Sample Controller" * diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/ui/SampleGroovyTemplateApplicationTests.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/ui/SampleGroovyTemplateApplicationTests.java index d1dd18a5e70..01baf02f7aa 100644 --- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/ui/SampleGroovyTemplateApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/ui/SampleGroovyTemplateApplicationTests.java @@ -16,10 +16,6 @@ package sample.ui; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.net.URI; import org.junit.Test; @@ -36,6 +32,10 @@ import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + /** * Basic integration tests for demo application. * diff --git a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/ui/method/SampleMethodSecurityApplication.java b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/ui/method/SampleMethodSecurityApplication.java index 3bbf1afb88e..6c1bb1ccf21 100644 --- a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/ui/method/SampleMethodSecurityApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/ui/method/SampleMethodSecurityApplication.java @@ -59,8 +59,7 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter { } public static void main(String[] args) throws Exception { - new SpringApplicationBuilder(SampleMethodSecurityApplication.class) - .run(args); + new SpringApplicationBuilder(SampleMethodSecurityApplication.class).run(args); } @Override @@ -83,26 +82,23 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter { public void init(AuthenticationManagerBuilder auth) throws Exception { // @formatter:off auth.inMemoryAuthentication().withUser("admin").password("admin") - .roles("ADMIN", "USER").and().withUser("user") - .password("user").roles("USER"); + .roles("ADMIN", "USER").and().withUser("user").password("user") + .roles("USER"); // @formatter:on } } @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER) - protected static class ApplicationSecurity extends - WebSecurityConfigurerAdapter { + protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off - http.authorizeRequests().antMatchers("/login").permitAll() - .anyRequest().fullyAuthenticated().and().formLogin() - .loginPage("/login").failureUrl("/login?error").and() - .logout() - .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) - .and().exceptionHandling() - .accessDeniedPage("/access?error"); + http.authorizeRequests().antMatchers("/login").permitAll().anyRequest() + .fullyAuthenticated().and().formLogin().loginPage("/login") + .failureUrl("/login?error").and().logout() + .logoutRequestMatcher(new AntPathRequestMatcher("/logout")).and() + .exceptionHandling().accessDeniedPage("/access?error"); // @formatter:on } diff --git a/spring-boot-samples/spring-boot-sample-web-method-security/src/test/java/sample/ui/method/SampleMethodSecurityApplicationTests.java b/spring-boot-samples/spring-boot-sample-web-method-security/src/test/java/sample/ui/method/SampleMethodSecurityApplicationTests.java index d8d219de944..4db71ecf862 100644 --- a/spring-boot-samples/spring-boot-sample-web-method-security/src/test/java/sample/ui/method/SampleMethodSecurityApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-web-method-security/src/test/java/sample/ui/method/SampleMethodSecurityApplicationTests.java @@ -16,9 +16,6 @@ package sample.ui.method; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -41,6 +38,9 @@ import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + /** * Basic integration tests for demo application. * diff --git a/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java b/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java index 747fd862b5d..a221e937db5 100644 --- a/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java @@ -52,8 +52,8 @@ public class SampleWebSecureApplication extends WebMvcConfigurerAdapter { public static void main(String[] args) throws Exception { // Set user password to "password" for demo purposes only - new SpringApplicationBuilder(SampleWebSecureApplication.class) - .properties("security.user.password=password").run(args); + new SpringApplicationBuilder(SampleWebSecureApplication.class).properties( + "security.user.password=password").run(args); } @Override @@ -67,13 +67,11 @@ public class SampleWebSecureApplication extends WebMvcConfigurerAdapter { } @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER) - protected static class ApplicationSecurity extends - WebSecurityConfigurerAdapter { + protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().fullyAuthenticated().and() - .formLogin().loginPage("/login").failureUrl("/login?error") - .permitAll(); + http.authorizeRequests().anyRequest().fullyAuthenticated().and().formLogin() + .loginPage("/login").failureUrl("/login?error").permitAll(); } } diff --git a/spring-boot-samples/spring-boot-sample-web-velocity/src/test/java/sample/velocity/SampleWebVelocityApplicationTests.java b/spring-boot-samples/spring-boot-sample-web-velocity/src/test/java/sample/velocity/SampleWebVelocityApplicationTests.java index b3032d86230..025a03d703b 100644 --- a/spring-boot-samples/spring-boot-sample-web-velocity/src/test/java/sample/velocity/SampleWebVelocityApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-web-velocity/src/test/java/sample/velocity/SampleWebVelocityApplicationTests.java @@ -39,7 +39,7 @@ import static org.junit.Assert.assertTrue; /** * Basic integration tests for Velocity application. - * + * * @author Phillip Webb * @author Andy Wilkinson */ diff --git a/spring-boot-tools/spring-boot-dependency-tools/pom.xml b/spring-boot-tools/spring-boot-dependency-tools/pom.xml index a2811972f85..75abdbee79e 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/pom.xml +++ b/spring-boot-tools/spring-boot-dependency-tools/pom.xml @@ -129,5 +129,4 @@ - diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PomManagedDependencies.java b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PomManagedDependencies.java index 2027822a631..5a426130855 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PomManagedDependencies.java +++ b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PomManagedDependencies.java @@ -30,8 +30,9 @@ import org.w3c.dom.NodeList; /** * {@link ManagedDependencies} implementation backed a maven POM. - * + * * @author Phillip Webb + * @author Andy Wilkinson * @since 1.1.0 */ public class PomManagedDependencies extends AbstractManagedDependencies { diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PropertiesFileManagedDependencies.java b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PropertiesFileManagedDependencies.java index 4ba46b6765b..13058833117 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PropertiesFileManagedDependencies.java +++ b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PropertiesFileManagedDependencies.java @@ -26,7 +26,7 @@ import java.util.TreeMap; * {@link ManagedDependencies} backed by an external properties file (of the form created * by the Spring IO platform). The property key should be the groupId and artifactId (in * the form {@literal groupId:artifactId}) and the value should be the version. - * + * * @author Phillip Webb * @since 1.1.0 */ diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/VersionManagedDependencies.java b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/VersionManagedDependencies.java index 7bb4ed3f256..d4f327cf52f 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/VersionManagedDependencies.java +++ b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/VersionManagedDependencies.java @@ -24,7 +24,7 @@ import java.util.Collections; * {@link ManagedDependencies} used by various spring boot tools. Provides programmatic * access to 'spring-boot-dependencies' and can also support user defined version managed * dependencies. - * + * * @author Phillip Webb * @since 1.1.0 */ diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/test/java/org/springframework/boot/dependency/tools/PomManagedDependenciesTests.java b/spring-boot-tools/spring-boot-dependency-tools/src/test/java/org/springframework/boot/dependency/tools/PomManagedDependenciesTests.java index 4af1567345c..ba93460df95 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/src/test/java/org/springframework/boot/dependency/tools/PomManagedDependenciesTests.java +++ b/spring-boot-tools/spring-boot-dependency-tools/src/test/java/org/springframework/boot/dependency/tools/PomManagedDependenciesTests.java @@ -29,7 +29,7 @@ import static org.junit.Assert.assertThat; /** * Tests for {@link PomManagedDependencies}. - * + * * @author Phillip Webb */ public class PomManagedDependenciesTests { diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 5be57a0a381..95936845e02 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -28,7 +28,7 @@ import org.springframework.boot.loader.util.AsciiBytes; /** * {@link java.net.JarURLConnection} used to support {@link JarFile#getUrl()}. - * + * * @author Phillip Webb */ class JarURLConnection extends java.net.JarURLConnection { diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractDependencyFilterMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractDependencyFilterMojo.java index 5f6a8aafc85..2e975669dc7 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractDependencyFilterMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractDependencyFilterMojo.java @@ -95,7 +95,8 @@ public abstract class AbstractDependencyFilterMojo extends AbstractMojo { } filters.addFilter(new ArtifactIdFilter("", cleanFilterConfig(this.excludeArtifactIds))); - filters.addFilter(new MatchingGroupIdFilter(cleanFilterConfig(this.excludeGroupIds))); + filters.addFilter(new MatchingGroupIdFilter( + cleanFilterConfig(this.excludeGroupIds))); if (this.excludes != null) { filters.addFilter(new ExcludeFilter(this.excludes)); } diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MatchingGroupIdFilter.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MatchingGroupIdFilter.java index a2f2632d26a..d4cd442db41 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MatchingGroupIdFilter.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MatchingGroupIdFilter.java @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.maven; import org.apache.maven.artifact.Artifact; @@ -6,10 +22,11 @@ import org.apache.maven.shared.artifact.filter.collection.AbstractArtifactFeatur /** * An {@link org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter * ArtifactsFilter} that filters by matching groupId. - * - * Preferred over the {@link org.apache.maven.shared.artifact.filter.collection.GroupIdFilter} due - * to that classes use of {@link String#startsWith} to match on prefix. - * + * + * Preferred over the + * {@link org.apache.maven.shared.artifact.filter.collection.GroupIdFilter} due to that + * classes use of {@link String#startsWith} to match on prefix. + * * @author Mark Ingram * @since 1.1 */ @@ -22,7 +39,9 @@ public class MatchingGroupIdFilter extends AbstractArtifactFeatureFilter { super("", exclude); } + @Override protected String getArtifactFeature(Artifact artifact) { return artifact.getGroupId(); } + } diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/DependencyFilterMojoTests.java b/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/DependencyFilterMojoTests.java index 4d51f765592..e53205d06ba 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/DependencyFilterMojoTests.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/DependencyFilterMojoTests.java @@ -33,6 +33,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; /** + * Tests for {@link AbstractDependencyFilterMojo}. * * @author Stephane Nicoll */ @@ -54,7 +55,7 @@ public class DependencyFilterMojoTests { @Test public void filterGroupIdExactMatch() throws MojoExecutionException { TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo( - Collections.emptyList(), "com.foo", ""); + Collections. emptyList(), "com.foo", ""); Artifact artifact = createArtifact("com.foo.bar", "one"); Set artifacts = mojo.filterDependencies( @@ -91,5 +92,6 @@ public class DependencyFilterMojoTests { public void execute() throws MojoExecutionException, MojoFailureException { } + } } diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java index 9f3243339ef..5b0c8cafd3a 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java @@ -31,7 +31,9 @@ import org.springframework.boot.context.embedded.AbstractEmbeddedServletContaine import org.springframework.util.SocketUtils; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyObject; import static org.mockito.Mockito.inOrder;