diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataEndpointMBean.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataEndpointMBean.java index 0796c7fc2bb..385821119b1 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataEndpointMBean.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataEndpointMBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2012-2016 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,18 +32,6 @@ import org.springframework.jmx.export.annotation.ManagedResource; @ManagedResource public class DataEndpointMBean extends EndpointMBean { - /** - * Create a new {@link DataEndpointMBean} instance. - * @param beanName the bean name - * @param endpoint the endpoint to wrap - * @deprecated since 1.3 in favor of - * {@link #DataEndpointMBean(String, Endpoint, ObjectMapper)} - */ - @Deprecated - public DataEndpointMBean(String beanName, Endpoint endpoint) { - super(beanName, endpoint); - } - /** * Create a new {@link DataEndpointMBean} instance. * @param beanName the bean name diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBean.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBean.java index eac0dc9816a..2a6cec2f3a6 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBean.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -40,18 +40,6 @@ public class EndpointMBean { private final ObjectMapper mapper; - /** - * Create a new {@link EndpointMBean} instance. - * @param beanName the bean name - * @param endpoint the endpoint to wrap - * @deprecated since 1.3 in favor of - * {@link #EndpointMBean(String, Endpoint, ObjectMapper)} - */ - @Deprecated - public EndpointMBean(String beanName, Endpoint endpoint) { - this(beanName, endpoint, new ObjectMapper()); - } - /** * Create a new {@link EndpointMBean} instance. * @param beanName the bean name diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java index 1f5ffb1f071..1af2ec2477f 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2012-2016 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,18 +32,6 @@ import org.springframework.jmx.export.annotation.ManagedResource; @ManagedResource public class ShutdownEndpointMBean extends EndpointMBean { - /** - * Create a new {@link ShutdownEndpointMBean} instance. - * @param beanName the bean name - * @param endpoint the endpoint to wrap - * @deprecated since 1.3 in favor of - * {@link #ShutdownEndpointMBean(String, Endpoint, ObjectMapper)} - */ - @Deprecated - public ShutdownEndpointMBean(String beanName, Endpoint endpoint) { - super(beanName, endpoint); - } - /** * Create a new {@link ShutdownEndpointMBean} instance. * @param beanName the bean name diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DropwizardMetricWriter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DropwizardMetricWriter.java deleted file mode 100644 index 6e4793b0dfb..00000000000 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DropwizardMetricWriter.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2012-2015 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.actuate.metrics.writer; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.TimeUnit; - -import com.codahale.metrics.Counter; -import com.codahale.metrics.Gauge; -import com.codahale.metrics.Histogram; -import com.codahale.metrics.Meter; -import com.codahale.metrics.MetricRegistry; -import com.codahale.metrics.Timer; - -import org.springframework.boot.actuate.metrics.Metric; -import org.springframework.boot.actuate.metrics.dropwizard.DropwizardMetricServices; - -/** - * A {@link MetricWriter} that send data to a Dropwizard {@link MetricRegistry} based on a - * naming convention. - * - * - * - * @author Dave Syer - * @deprecated Since 1.3 in favor of {@link DropwizardMetricServices} - */ -@Deprecated -public class DropwizardMetricWriter implements MetricWriter { - - private final MetricRegistry registry; - - private final ConcurrentMap gaugeLocks = new ConcurrentHashMap(); - - /** - * Create a new {@link DropwizardMetricWriter} instance. - * @param registry the underlying metric registry - */ - public DropwizardMetricWriter(MetricRegistry registry) { - this.registry = registry; - } - - @Override - public void increment(Delta delta) { - String name = delta.getName(); - long value = delta.getValue().longValue(); - if (name.startsWith("meter")) { - Meter meter = this.registry.meter(name); - meter.mark(value); - } - else { - Counter counter = this.registry.counter(name); - counter.inc(value); - } - } - - @Override - public void set(Metric value) { - String name = value.getName(); - if (name.startsWith("histogram")) { - long longValue = value.getValue().longValue(); - Histogram metric = this.registry.histogram(name); - metric.update(longValue); - } - else if (name.startsWith("timer")) { - long longValue = value.getValue().longValue(); - Timer metric = this.registry.timer(name); - metric.update(longValue, TimeUnit.MILLISECONDS); - } - else { - final double gauge = value.getValue().doubleValue(); - // Ensure we synchronize to avoid another thread pre-empting this thread after - // remove causing an error in Dropwizard Metrics - // NOTE: Dropwizard Metrics provides no way to do this atomically - synchronized (getGaugeLock(name)) { - this.registry.remove(name); - this.registry.register(name, new SimpleGauge(gauge)); - } - } - } - - private Object getGaugeLock(String name) { - Object lock = this.gaugeLocks.get(name); - if (lock == null) { - Object newLock = new Object(); - lock = this.gaugeLocks.putIfAbsent(name, newLock); - lock = (lock == null ? newLock : lock); - } - return lock; - } - - @Override - public void reset(String metricName) { - this.registry.remove(metricName); - } - - /** - * Simple {@link Gauge} implementation to {@literal double} value. - */ - private final static class SimpleGauge implements Gauge { - - private final double value; - - private SimpleGauge(double value) { - this.value = value; - } - - @Override - public Double getValue() { - return this.value; - } - - } - -} diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java index 0e47397833f..f0164bacf5c 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java @@ -62,17 +62,6 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order private final TraceProperties properties; - /** - * Create a new {@link WebRequestTraceFilter} instance. - * @param traceRepository the trace repository. - * @deprecated since 1.3.0 in favor of - * {@link #WebRequestTraceFilter(TraceRepository, TraceProperties)} - */ - @Deprecated - public WebRequestTraceFilter(TraceRepository traceRepository) { - this(traceRepository, new TraceProperties()); - } - /** * Create a new {@link WebRequestTraceFilter} instance. * @param repository the trace repository diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingClass.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingClass.java index c29712397a3..c1379212eb2 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingClass.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingClass.java @@ -42,12 +42,4 @@ public @interface ConditionalOnMissingClass { */ String[] value() default {}; - /** - * An alias for {@link #value} specifying the names of the classes that must not be - * present. - * @return the class names that must not be present. - * @deprecated since 1.3.0 in favor of {@link #value}. - */ - String[] name() default {}; - } 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 deleted file mode 100644 index 74bce178412..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateResolver.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2012-2015 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.groovy.template; - -import java.io.IOException; -import java.net.URL; - -import groovy.text.markup.MarkupTemplateEngine; -import groovy.text.markup.TemplateConfiguration; -import groovy.text.markup.TemplateResolver; - -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer; -import org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver; - -/** - * 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 - * @deprecated since 1.2 in favor of Spring 4.1's {@link GroovyMarkupViewResolver} and - * {@link GroovyMarkupConfigurer}. - */ -@Deprecated -public class GroovyTemplateResolver implements TemplateResolver { - - private ClassLoader 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 = 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/mongo/MongoProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java index ae3f8b643ca..10a44297b99 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java @@ -181,21 +181,6 @@ public class MongoProperties { return new MongoClientURI(this.uri).getDatabase(); } - /** - * Creates a {@link MongoClient} using the given {@code options}. - * - * @param options the options - * @return the Mongo client - * @throws UnknownHostException if the configured host is unknown - * @deprecated Since 1.3.0 in favour of - * {@link #createMongoClient(MongoClientOptions, Environment)} - */ - @Deprecated - public MongoClient createMongoClient(MongoClientOptions options) - throws UnknownHostException { - return this.createMongoClient(options, null); - } - /** * Creates a {@link MongoClient} using the given {@code options} and * {@code environment}. If the configured port is zero, the value of the 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 deleted file mode 100644 index e8d04a9ff6d..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilder.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2012-2015 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.orm.jpa; - -import java.util.Map; - -import javax.sql.DataSource; - -import org.springframework.orm.jpa.JpaVendorAdapter; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.persistenceunit.PersistenceUnitManager; - -/** - * Convenient builder for JPA EntityManagerFactory instances. Collects common - * configuration when constructed and then allows you to create one or more - * {@link LocalContainerEntityManagerFactoryBean} through a fluent builder pattern. The - * most common options are covered in the builder, but you can always manipulate the - * product of the builder if you need more control, before returning it from a - * {@code @Bean} definition. - * - * @author Dave Syer - * @since 1.1.0 - * @deprecated since 1.3.0 in favor of - * {@link org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder} - */ -@Deprecated -public class EntityManagerFactoryBuilder { - - private final Delegate delegate; - - /** - * Create a new instance passing in the common pieces that will be shared if multiple - * EntityManagerFactory instances are created. - * @param jpaVendorAdapter a vendor adapter - * @param properties common configuration options, including generic map for JPA - * vendor properties - * @param persistenceUnitManager optional source of persistence unit information (can - * be null) - */ - public EntityManagerFactoryBuilder(JpaVendorAdapter jpaVendorAdapter, - JpaProperties properties, PersistenceUnitManager persistenceUnitManager) { - this.delegate = new Delegate(jpaVendorAdapter, properties.getProperties(), - persistenceUnitManager); - } - - public Builder dataSource(DataSource dataSource) { - return new Builder(this.delegate.dataSource(dataSource)); - } - - /** - * An optional callback for new entity manager factory beans. - * @param callback the entity manager factory bean callback - */ - public void setCallback(final EntityManagerFactoryBeanCallback callback) { - this.delegate.setCallback( - new org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.EntityManagerFactoryBeanCallback() { - - @Override - public void execute(LocalContainerEntityManagerFactoryBean factory) { - callback.execute(factory); - } - - }); - } - - /** - * A fluent builder for a LocalContainerEntityManagerFactoryBean. - * @deprecated since 1.3.0 in favor of - * {@link org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder} - */ - @Deprecated - public final class Builder { - - private final org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.Builder delegate; - - private Builder( - org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.Builder delegate) { - this.delegate = delegate; - } - - /** - * The names of packages to scan for {@code @Entity} annotations. - * @param packagesToScan packages to scan - * @return the builder for fluent usage - */ - public Builder packages(String... packagesToScan) { - this.delegate.packages(packagesToScan); - return this; - } - - /** - * The classes whose packages should be scanned for {@code @Entity} annotations. - * @param basePackageClasses the classes to use - * @return the builder for fluent usage - */ - public Builder packages(Class... basePackageClasses) { - this.delegate.packages(basePackageClasses); - return this; - } - - /** - * The name of the persistence unit. If only building one EntityManagerFactory you - * can omit this, but if there are more than one in the same application you - * should give them distinct names. - * @param persistenceUnit the name of the persistence unit - * @return the builder for fluent usage - */ - public Builder persistenceUnit(String persistenceUnit) { - this.delegate.persistenceUnit(persistenceUnit); - return this; - } - - /** - * Generic properties for standard JPA or vendor-specific configuration. These - * properties override any values provided in the {@link JpaProperties} used to - * create the builder. - * @param properties the properties to use - * @return the builder for fluent usage - */ - public Builder properties(Map properties) { - this.delegate.properties(properties); - return this; - } - - /** - * Configure if using a JTA {@link DataSource}, i.e. if - * {@link LocalContainerEntityManagerFactoryBean#setDataSource(DataSource) - * setDataSource} or - * {@link LocalContainerEntityManagerFactoryBean#setJtaDataSource(DataSource) - * setJtaDataSource} should be called on the - * {@link LocalContainerEntityManagerFactoryBean}. - * @param jta if the data source is JTA - * @return the builder for fluent usage - */ - public Builder jta(boolean jta) { - this.delegate.jta(jta); - return this; - } - - public LocalContainerEntityManagerFactoryBean build() { - return this.delegate.build(); - } - - } - - /** - * A callback for new entity manager factory beans created by a Builder. - * @deprecated since 1.3.0 in favor of - * {@link org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder} - */ - @Deprecated - public interface EntityManagerFactoryBeanCallback { - - void execute(LocalContainerEntityManagerFactoryBean factory); - - } - - private static class Delegate - extends org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder { - - Delegate(JpaVendorAdapter jpaVendorAdapter, Map jpaProperties, - PersistenceUnitManager persistenceUnitManager) { - super(jpaVendorAdapter, jpaProperties, persistenceUnitManager); - } - - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java index 7755315c4d6..5126f3244f8 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -51,17 +51,6 @@ public class BasicErrorController extends AbstractErrorController { private final ErrorProperties errorProperties; - /** - * Create a new {@link BasicErrorController} instance. - * @param errorAttributes the error attributes - * @deprecated since 1.3.0 in favor of - * {@link #BasicErrorController(ErrorAttributes, ErrorProperties)} - */ - @Deprecated - public BasicErrorController(ErrorAttributes errorAttributes) { - this(errorAttributes, new ErrorProperties()); - } - /** * Create a new {@link BasicErrorController} instance. * @param errorAttributes the error attributes diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 6c8b2fcc972..80d61fcb9a5 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -55,7 +55,6 @@ import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.context.EnvironmentAware; import org.springframework.core.Ordered; @@ -327,27 +326,6 @@ public class ServerProperties return (platform == null ? false : platform.isUsingForwardHeaders()); } - /** - * Get the session timeout. - * @return the session timeout - * @deprecated since 1.3.0 in favor of {@code session.timeout}. - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "server.session.timeout") - public Integer getSessionTimeout() { - return this.session.getTimeout(); - } - - /** - * Set the session timeout. - * @param sessionTimeout the session timeout - * @deprecated since 1.3.0 in favor of {@code session.timeout}. - */ - @Deprecated - public void setSessionTimeout(Integer sessionTimeout) { - this.session.setTimeout(sessionTimeout); - } - public ErrorProperties getError() { return this.error; } @@ -632,48 +610,6 @@ public class ServerProperties return this.accesslog; } - /** - * Specify if access log is enabled. - * @return {@code true} if access log is enabled - * @deprecated since 1.3.0 in favor of {@code server.tomcat.accesslog.enabled} - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "server.tomcat.accesslog.enabled") - public boolean getAccessLogEnabled() { - return this.accesslog.isEnabled(); - } - - /** - * Set if access log is enabled. - * @param accessLogEnabled the access log enable flag - * @deprecated since 1.3.0 in favor of {@code server.tomcat.accesslog.enabled} - */ - @Deprecated - public void setAccessLogEnabled(boolean accessLogEnabled) { - getAccesslog().setEnabled(accessLogEnabled); - } - - /** - * Get the format pattern for access logs. - * @return the format pattern for access logs - * @deprecated since 1.3.0 in favor of {@code server.tomcat.accesslog.pattern} - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "server.tomcat.accesslog.pattern") - public String getAccessLogPattern() { - return this.accesslog.getPattern(); - } - - /** - * Set the format pattern for access logs. - * @param accessLogPattern the pattern for access logs - * @deprecated since 1.3.0 in favor of {@code server.tomcat.accesslog.pattern} - */ - @Deprecated - public void setAccessLogPattern(String accessLogPattern) { - this.accesslog.setPattern(accessLogPattern); - } - public int getBackgroundProcessorDelay() { return this.backgroundProcessorDelay; } @@ -990,69 +926,6 @@ public class ServerProperties return this.accesslog; } - /** - * Get the format pattern for access logs. - * @return the format pattern for access logs - * @deprecated since 1.3.0 in favor of {@code server.undertow.accesslog.pattern} - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "server.undertow.accesslog.pattern") - public String getAccessLogPattern() { - return this.accesslog.getPattern(); - } - - /** - * Set the format pattern for access logs. - * @param accessLogPattern the pattern for access logs - * @deprecated since 1.3.0 in favor of {@code server.undertow.accesslog.pattern} - */ - @Deprecated - public void setAccessLogPattern(String accessLogPattern) { - this.accesslog.setPattern(accessLogPattern); - } - - /** - * Specify if access log is enabled. - * @return {@code true} if access log is enabled - * @deprecated since 1.3.0 in favor of {@code server.undertow.accesslog.enabled} - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "server.undertow.accesslog.enabled") - public boolean isAccessLogEnabled() { - return this.accesslog.isEnabled(); - } - - /** - * Set if access log is enabled. - * @param accessLogEnabled the access log enable flag - * @deprecated since 1.3.0 in favor of {@code server.undertow.accesslog.enabled} - */ - @Deprecated - public void setAccessLogEnabled(boolean accessLogEnabled) { - getAccesslog().setEnabled(accessLogEnabled); - } - - /** - * Get the access log directory. - * @return the access log directory - * @deprecated since 1.3.0 in favor of {@code server.undertow.accesslog.dir} - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "server.undertow.accesslog.dir") - public File getAccessLogDir() { - return this.accesslog.getDir(); - } - - /** - * Set the access log directory. - * @param accessLogDir the access log directory - * @deprecated since 1.3.0 in favor of {@code server.tomcat.accesslog.dir} - */ - @Deprecated - public void setAccessLogDir(File accessLogDir) { - getAccesslog().setDir(accessLogDir); - } - void customizeUndertow(ServerProperties serverProperties, UndertowEmbeddedServletContainerFactory factory) { factory.setBufferSize(this.bufferSize); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingClassTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingClassTests.java index 04176fc1a04..c9a604dc5f1 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingClassTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingClassTests.java @@ -61,7 +61,7 @@ public class ConditionalOnMissingClassTests { } @Configuration - @ConditionalOnMissingClass(name = "FOO") + @ConditionalOnMissingClass("FOO") protected static class MissingConfiguration { @Bean public String bar() { 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 deleted file mode 100644 index 6654e5f43a0..00000000000 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderTests.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2012-2015 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.orm.jpa; - -import java.util.Collections; - -import javax.sql.DataSource; - -import org.junit.Test; - -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -/** - * Tests for {@link EntityManagerFactoryBuilder}. - * - * @author Dave Syer - */ -@Deprecated -public class EntityManagerFactoryBuilderTests { - - private JpaProperties properties = new JpaProperties(); - - private DataSource dataSource1 = mock(DataSource.class); - - private DataSource dataSource2 = mock(DataSource.class); - - @Test - public void entityManagerFactoryPropertiesNotOverwritingDefaults() { - EntityManagerFactoryBuilder factory = new EntityManagerFactoryBuilder( - new HibernateJpaVendorAdapter(), this.properties, null); - LocalContainerEntityManagerFactoryBean result1 = factory - .dataSource(this.dataSource1) - .properties(Collections.singletonMap("foo", "spam")).build(); - assertFalse(result1.getJpaPropertyMap().isEmpty()); - assertTrue(this.properties.getProperties().isEmpty()); - } - - @Test - public void multipleEntityManagerFactoriesDoNotOverwriteEachOther() { - EntityManagerFactoryBuilder factory = new EntityManagerFactoryBuilder( - new HibernateJpaVendorAdapter(), this.properties, null); - LocalContainerEntityManagerFactoryBean result1 = factory - .dataSource(this.dataSource1) - .properties(Collections.singletonMap("foo", "spam")).build(); - assertFalse(result1.getJpaPropertyMap().isEmpty()); - LocalContainerEntityManagerFactoryBean result2 = factory - .dataSource(this.dataSource2).build(); - assertTrue(result2.getJpaPropertyMap().isEmpty()); - } - -} diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 4d14c8a07db..a44df9699b4 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -110,7 +110,6 @@ 1.2 4.12 3.4.2 - 1.2.17 2.4.1 1.1.3 1.2.3 @@ -362,11 +361,6 @@ spring-boot-starter-undertow 1.4.0.BUILD-SNAPSHOT - - org.springframework.boot - spring-boot-starter-log4j - 1.4.0.BUILD-SNAPSHOT - org.springframework.boot spring-boot-starter-log4j2 @@ -854,11 +848,6 @@ junit ${junit.version} - - log4j - log4j - ${log4j.version} - mysql mysql-connector-java diff --git a/spring-boot-docs/pom.xml b/spring-boot-docs/pom.xml index a33396a2a91..30ea7fae875 100644 --- a/spring-boot-docs/pom.xml +++ b/spring-boot-docs/pom.xml @@ -177,11 +177,6 @@ junit true - - log4j - log4j - true - net.sf.ehcache ehcache diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 40188e50db9..8e14623edc8 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1313,12 +1313,11 @@ You also need to add `logging.file` to your `application.properties`: [[howto-configure-log4j-for-logging]] === Configure Log4j for logging -Spring Boot also supports either http://logging.apache.org/log4j/1.2[Log4j] or -http://logging.apache.org/log4j/2.x[Log4j 2] for logging configuration, but only if one -of them is on the classpath. If you are using the starter poms for assembling -dependencies that means you have to exclude Logback and then include your chosen version -of Log4j instead. If you aren't using the starter poms then you need to provide -`commons-logging` (at least) in addition to your chosen version of Log4j. +Spring Boot supports http://logging.apache.org/log4j/2.x[Log4j 2] for logging +configuration if it is on the classpath. If you are using the starter poms for +assembling dependencies that means you have to exclude Logback and then include log4j 2 +instead. If you aren't using the starter poms then you need to provide `commons-logging` +(at least) in addition to Log4j 2. The simplest path is probably through the starter poms, even though it requires some jiggling with excludes, .e.g. in Maven: @@ -1341,17 +1340,14 @@ jiggling with excludes, .e.g. in Maven: org.springframework.boot - spring-boot-starter-log4j + spring-boot-starter-log4j2 ---- -To use Log4j 2, simply depend on `spring-boot-starter-log4j2` rather than -`spring-boot-starter-log4j`. - -NOTE: The use of one of the Log4j starters gathers together the dependencies for -common logging requirements (e.g. including having Tomcat use `java.util.logging` but -configuring the output using Log4j or Log4j 2). See the Actuator Log4j or Log4j 2 -samples for more detail and to see it in action. +NOTE: The use of the Log4j starters gathers together the dependencies for common logging +requirements (e.g. including having Tomcat use `java.util.logging` but configuring the +output using Log4j 2). See the Actuator Log4j 2 samples for more detail and to see it in +action. 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 88ac4b99762..7aa7582164a 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -983,9 +983,9 @@ Spring Boot uses http://commons.apache.org/logging[Commons Logging] for all inte logging, but leaves the underlying log implementation open. Default configurations are provided for http://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html[Java Util Logging], -http://logging.apache.org/log4j/[Log4J], http://logging.apache.org/log4j/2.x/[Log4J2] and -http://logback.qos.ch/[Logback]. In each case loggers are pre-configured to use console -output with optional file output also available. +http://logging.apache.org/log4j/2.x/[Log4J2] andhttp://logback.qos.ch/[Logback]. In each +case loggers are pre-configured to use console output with optional file output also +available. By default, If you use the '`Starter POMs`', Logback will be used for logging. Appropriate Logback routing is also included to ensure that dependent libraries that use @@ -1182,9 +1182,6 @@ Depending on your logging system, the following files will be loaded: |Logback |`logback-spring.xml`, `logback-spring.groovy`, `logback.xml` or `logback.groovy` -|Log4j -|`log4j-spring.properties`, `log4j-spring.xml`, `log4j.properties` or `log4j.xml` - |Log4j2 |`log4j2-spring.xml` or `log4j2.xml` diff --git a/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc b/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc index e5224c16df9..c2a414ea8b3 100644 --- a/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc +++ b/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc @@ -517,8 +517,8 @@ swap specific technical facets. |`spring-boot-starter-jetty` |Imports the Jetty HTTP engine (to be used as an alternative to Tomcat). -|`spring-boot-starter-log4j` -|Support the Log4J logging framework. +|`spring-boot-starter-log4j2` +|Support the Log4J 2 logging framework. |`spring-boot-starter-logging` |Import Spring Boot's default logging framework (Logback). diff --git a/spring-boot-parent/pom.xml b/spring-boot-parent/pom.xml index d3e22d88c50..d8e0f41c6d3 100755 --- a/spring-boot-parent/pom.xml +++ b/spring-boot-parent/pom.xml @@ -42,6 +42,11 @@ + + log4j + log4j + 1.2.17 + com.google.guava guava diff --git a/spring-boot-samples/README.adoc b/spring-boot-samples/README.adoc index d33ed22cd04..469eedb13e5 100644 --- a/spring-boot-samples/README.adoc +++ b/spring-boot-samples/README.adoc @@ -14,8 +14,8 @@ -- A web UI example with production features * link:spring-boot-sample-actuator-noweb[spring-boot-sample-actuator-noweb] -- A production features sample with no web application -* link:spring-boot-sample-actuator-log4j[spring-boot-sample-actuator-log4j] - -- A production features sample using log4j for logging (instead of logback) +* link:spring-boot-sample-actuator-log4j2[spring-boot-sample-actuator-log4j2] + -- A production features sample using log4j 2 for logging (instead of logback) * link:spring-boot-sample-cache[spring-boot-sample-cache] -- A web sample that uses Spring's cache abstraction * link:spring-boot-sample-web-ui[spring-boot-sample-web-ui] diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index 156182549bb..4e7446eb03f 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -24,7 +24,6 @@ spring-boot-sample-ant spring-boot-sample-activemq spring-boot-sample-actuator - spring-boot-sample-actuator-log4j spring-boot-sample-actuator-log4j2 spring-boot-sample-actuator-noweb spring-boot-sample-actuator-ui diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j/pom.xml b/spring-boot-samples/spring-boot-sample-actuator-log4j/pom.xml deleted file mode 100644 index 64a17e3e954..00000000000 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-samples - 1.4.0.BUILD-SNAPSHOT - - spring-boot-sample-actuator-log4j - Spring Boot Actuator Log4j Sample - Spring Boot Actuator Log4j Sample - http://projects.spring.io/spring-boot/ - - Pivotal Software, Inc. - http://www.spring.io - - - ${basedir}/../.. - - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-log4j - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-starter-logging - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/HelloWorldService.java b/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/HelloWorldService.java deleted file mode 100644 index e7ba565979d..00000000000 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/HelloWorldService.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2012-2013 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 sample.actuator.log4j; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class HelloWorldService { - - @Autowired - private ServiceProperties configuration; - - public String getHelloMessage() { - return "Hello " + this.configuration.getName(); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/SampleActuatorLog4JApplication.java b/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/SampleActuatorLog4JApplication.java deleted file mode 100644 index 66c1edc98b0..00000000000 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/SampleActuatorLog4JApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2012-2013 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 sample.actuator.log4j; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SampleActuatorLog4JApplication { - - public static void main(String[] args) throws Exception { - SpringApplication.run(SampleActuatorLog4JApplication.class, args); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/SampleController.java b/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/SampleController.java deleted file mode 100644 index 43ea0749818..00000000000 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/SampleController.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2012-2013 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 sample.actuator.log4j; - -import java.util.Collections; -import java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class SampleController { - - @Autowired - private HelloWorldService helloWorldService; - - @RequestMapping("/") - @ResponseBody - public Map helloWorld() { - return Collections.singletonMap("message", - this.helloWorldService.getHelloMessage()); - } - - @RequestMapping("/foo") - @ResponseBody - public String foo() { - throw new IllegalArgumentException("Server error"); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/ServiceProperties.java b/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/ServiceProperties.java deleted file mode 100644 index 65194e1443b..00000000000 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/java/sample/actuator/log4j/ServiceProperties.java +++ /dev/null @@ -1,36 +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 sample.actuator.log4j; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false) -@Component -public class ServiceProperties { - - private String name = "World"; - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/resources/application.properties deleted file mode 100644 index 68952c2ab7f..00000000000 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/resources/application.properties +++ /dev/null @@ -1,17 +0,0 @@ -#logging.file: /tmp/logs/app.log -#server.port: 8080 -#management.port: 8080 -management.address: 127.0.0.1 -endpoints.shutdown.enabled: true -server.tomcat.basedir: target/tomcat -server.tomcat.access_log_pattern: %h %t "%r" %s %b -security.require_ssl: false -service.name: Phil -shell.ssh.enabled: true -shell.ssh.port: 2222 -#shell.telnet.enabled: false -#shell.telnet.port: 1111 -shell.auth: spring -#shell.auth: key -#shell.auth.key.path: ${user.home}/test/id_rsa.pub.pem -#shell.auth: simple diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/resources/log4j.properties b/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/resources/log4j.properties deleted file mode 100644 index 6070be6142a..00000000000 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/main/resources/log4j.properties +++ /dev/null @@ -1,14 +0,0 @@ -log4j.rootCategory=INFO, CONSOLE - -PID=???? -LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] log4j%X{context} - ${PID} %5p [%t] --- %c{1}: %m%n - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN} - -log4j.category.org.hibernate.validator.internal.util.Version=WARN -log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN -log4j.category.org.apache.tomcat.util.net.NioSelectorPool=WARN -log4j.category.org.apache.catalina.startup.DigesterFactory=ERROR 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 deleted file mode 100644 index c02141e5d43..00000000000 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j/src/test/java/sample/actuator/log4j/SampleActuatorApplicationTests.java +++ /dev/null @@ -1,72 +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 sample.actuator.log4j; - -import java.util.Map; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.boot.test.TestRestTemplate; -import org.springframework.boot.test.WebIntegrationTest; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Basic integration tests for service demo application. - * - * @author Dave Syer - */ -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(SampleActuatorLog4JApplication.class) -@WebIntegrationTest(randomPort = true) -@DirtiesContext -public class SampleActuatorApplicationTests { - - @Value("${local.server.port}") - private int port; - - @Test - public void testHome() throws Exception { - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port, Map.class); - assertEquals(HttpStatus.OK, entity.getStatusCode()); - @SuppressWarnings("unchecked") - Map body = entity.getBody(); - assertEquals("Hello Phil", body.get("message")); - } - - @Test - public void testHealth() throws Exception { - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/health", Map.class); - assertEquals(HttpStatus.OK, entity.getStatusCode()); - @SuppressWarnings("unchecked") - Map body = entity.getBody(); - assertNotNull(body.get("diskSpace")); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-traditional/src/main/resources/log4j.properties b/spring-boot-samples/spring-boot-sample-traditional/src/main/resources/log4j.properties deleted file mode 100644 index 17a835fafff..00000000000 --- a/spring-boot-samples/spring-boot-sample-traditional/src/main/resources/log4j.properties +++ /dev/null @@ -1,7 +0,0 @@ -log4j.rootCategory=INFO, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n - -log4j.category.org.springframework.web=DEBUG diff --git a/spring-boot-starters/pom.xml b/spring-boot-starters/pom.xml index 93413d4d072..c0b9af6f5c4 100644 --- a/spring-boot-starters/pom.xml +++ b/spring-boot-starters/pom.xml @@ -46,7 +46,6 @@ spring-boot-starter-jta-atomikos spring-boot-starter-jta-bitronix spring-boot-starter-logging - spring-boot-starter-log4j spring-boot-starter-log4j2 spring-boot-starter-mail spring-boot-starter-mobile diff --git a/spring-boot-starters/spring-boot-starter-log4j/pom.xml b/spring-boot-starters/spring-boot-starter-log4j/pom.xml deleted file mode 100644 index 65e8a1a29ad..00000000000 --- a/spring-boot-starters/spring-boot-starter-log4j/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starters - 1.4.0.BUILD-SNAPSHOT - - spring-boot-starter-log4j - Spring Boot Log4J Starter - Spring Boot Log4J Starter - http://projects.spring.io/spring-boot/ - - Pivotal Software, Inc. - http://www.spring.io - - - ${basedir}/../.. - - - - org.slf4j - jcl-over-slf4j - - - org.slf4j - jul-to-slf4j - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - diff --git a/spring-boot-starters/spring-boot-starter-log4j/src/main/resources/META-INF/spring.provides b/spring-boot-starters/spring-boot-starter-log4j/src/main/resources/META-INF/spring.provides deleted file mode 100644 index 76057bd232c..00000000000 --- a/spring-boot-starters/spring-boot-starter-log4j/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1 +0,0 @@ -provides: log4j,slf4j-log4j12 \ No newline at end of file diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-exclude-group/pom.xml b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-exclude-group/pom.xml index eee4f1c4a30..34abd051309 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-exclude-group/pom.xml +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-exclude-group/pom.xml @@ -20,7 +20,7 @@ repackage - log4j + org.apache.logging.log4j @@ -52,9 +52,9 @@ provided - log4j - log4j - 1.2.17 + org.apache.logging.log4j + log4j-api + 2.4.1 diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-exclude-group/verify.groovy b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-exclude-group/verify.groovy index f03bbb3a839..9d326f53cbf 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-exclude-group/verify.groovy +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-exclude-group/verify.groovy @@ -22,6 +22,6 @@ new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) { @Override protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception { super.verifyZipEntries(verifier) - verifier.assertHasNoEntryNameStartingWith("lib/log4j-1.2.17.jar") + verifier.assertHasNoEntryNameStartingWith("lib/log4j-api-2.4.1.jar") } }.verify(); diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-test-scope/pom.xml b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-test-scope/pom.xml index 994945fae53..d3ba2034a6f 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-test-scope/pom.xml +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-test-scope/pom.xml @@ -52,9 +52,9 @@ provided - log4j - log4j - @log4j.version@ + org.apache.logging.log4j + log4j-api + 2.4.1 test diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-test-scope/verify.groovy b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-test-scope/verify.groovy index b76415b150b..1952298b0be 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-test-scope/verify.groovy +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-test-scope/verify.groovy @@ -22,6 +22,6 @@ new Verify.JarArchiveVerification(f, Verify.SAMPLE_APP) { @Override protected void verifyZipEntries(Verify.ArchiveVerifier verifier) throws Exception { super.verifyZipEntries(verifier) - verifier.assertHasNoEntryNameStartingWith("lib/log4j-1.2.17.jar") + verifier.assertHasNoEntryNameStartingWith("lib/log4j-api-2.4.1.jar") } }.verify(); diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-with-unpack/pom.xml b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-with-unpack/pom.xml index 3349f7ecd0b..015944e662e 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-with-unpack/pom.xml +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-with-unpack/pom.xml @@ -57,9 +57,9 @@ provided - log4j - log4j - @log4j.version@ + org.apache.logging.log4j + log4j-api + @log4j2.version@ diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/run-exclude/pom.xml b/spring-boot-tools/spring-boot-maven-plugin/src/it/run-exclude/pom.xml index 62394bd0e54..80d3cd142c6 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/it/run-exclude/pom.xml +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/run-exclude/pom.xml @@ -23,8 +23,8 @@ - log4j - log4j + org.apache.logging.log4j + log4j-api javax.servlet @@ -36,9 +36,9 @@ - log4j - log4j - @log4j.version@ + org.apache.logging.log4j + log4j-api + @log4j2.version@ javax.servlet diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index 4a31e66a695..0de33cba3b9 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -84,11 +84,6 @@ junit true - - log4j - log4j - true - org.apache.logging.log4j log4j-api diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 73a3f68a9ad..77a0511e4e0 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -773,7 +773,6 @@ public class SpringApplication { */ protected void afterRefresh(ConfigurableApplicationContext context, ApplicationArguments args) { - afterRefresh(context, args.getSourceArgs()); callRunners(context, args); } @@ -810,17 +809,6 @@ public class SpringApplication { } } - /** - * Called after the context has been refreshed. - * @param context the application context - * @param args the application arguments - * @deprecated in 1.3 in favor of - * {@link #afterRefresh(ConfigurableApplicationContext, ApplicationArguments)} - */ - @Deprecated - protected void afterRefresh(ConfigurableApplicationContext context, String[] args) { - } - private void handleRunFailure(ConfigurableApplicationContext context, SpringApplicationRunListeners listeners, Throwable exception) { if (logger.isErrorEnabled()) { @@ -969,17 +957,6 @@ public class SpringApplication { this.banner = banner; } - /** - * Sets if the Spring banner should be displayed when the application runs. Defaults - * to {@code true}. - * @param showBanner if the banner should be shown - * @deprecated since 1.3.0 in favor of {@link #setBannerMode} - */ - @Deprecated - public void setShowBanner(boolean showBanner) { - setBannerMode(showBanner ? Banner.Mode.CONSOLE : Banner.Mode.OFF); - } - /** * Sets the mode used to display the banner when the application runs. Defaults to * {@code Banner.Mode.CONSOLE}. diff --git a/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiElement.java b/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiElement.java index 9b664bc1192..d33924b458b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiElement.java +++ b/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -23,112 +23,10 @@ package org.springframework.boot.ansi; */ public interface AnsiElement { - /** - * @deprecated in 1.3.0 in favor of {@link AnsiStyle#NORMAL} - */ - @Deprecated - AnsiElement NORMAL = new DefaultAnsiElement("0"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiStyle#BOLD} - */ - @Deprecated - AnsiElement BOLD = new DefaultAnsiElement("1"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiStyle#FAINT} - */ - @Deprecated - AnsiElement FAINT = new DefaultAnsiElement("2"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiStyle#ITALIC} - */ - @Deprecated - AnsiElement ITALIC = new DefaultAnsiElement("3"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiStyle#UNDERLINE} - */ - @Deprecated - AnsiElement UNDERLINE = new DefaultAnsiElement("4"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiColor#BLACK} - */ - @Deprecated - AnsiElement BLACK = new DefaultAnsiElement("30"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiColor#RED} - */ - @Deprecated - AnsiElement RED = new DefaultAnsiElement("31"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiColor#GREEN} - */ - @Deprecated - AnsiElement GREEN = new DefaultAnsiElement("32"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiColor#YELLOW} - */ - @Deprecated - AnsiElement YELLOW = new DefaultAnsiElement("33"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiColor#BLUE} - */ - @Deprecated - AnsiElement BLUE = new DefaultAnsiElement("34"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiColor#MAGENTA} - */ - @Deprecated - AnsiElement MAGENTA = new DefaultAnsiElement("35"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiColor#CYAN} - */ - @Deprecated - AnsiElement CYAN = new DefaultAnsiElement("36"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiColor#WHITE} - */ - @Deprecated - AnsiElement WHITE = new DefaultAnsiElement("37"); - - /** - * @deprecated in 1.3.0 in favor of {@link AnsiColor#DEFAULT} - */ - @Deprecated - AnsiElement DEFAULT = new DefaultAnsiElement("39"); - /** * @return the ANSI escape code */ @Override String toString(); - /** - * Internal default {@link AnsiElement} implementation. - */ - class DefaultAnsiElement implements AnsiElement { - - private final String code; - - DefaultAnsiElement(String code) { - this.code = code; - } - - @Override - public String toString() { - return this.code; - } - - } - } diff --git a/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java b/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index e0e0728e50a..84a57d2c07c 100644 --- a/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java +++ b/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -313,18 +313,6 @@ public class SpringApplicationBuilder { return this; } - /** - * Flag to indicate the startup banner should be printed. - * @param showBanner the flag to set. Default true. - * @return the current builder - * @deprecated Since 1.3.0 in favor of {@link #bannerMode} - */ - @Deprecated - public SpringApplicationBuilder showBanner(boolean showBanner) { - this.application.setShowBanner(showBanner); - return this; - } - public SpringApplicationBuilder bannerMode(Banner.Mode bannerMode) { this.application.setBannerMode(bannerMode); return this; diff --git a/spring-boot/src/main/java/org/springframework/boot/cloudfoundry/VcapEnvironmentPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/cloudfoundry/VcapEnvironmentPostProcessor.java deleted file mode 100644 index 5cb0cb11bd6..00000000000 --- a/spring-boot/src/main/java/org/springframework/boot/cloudfoundry/VcapEnvironmentPostProcessor.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2010-2015 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.cloudfoundry; - -import org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.Environment; - -/** - * An {@link EnvironmentPostProcessor} that knows where to find VCAP (a.k.a. Cloud - * Foundry) meta data in the existing environment. It parses out the VCAP_APPLICATION and - * VCAP_SERVICES meta data and dumps it in a form that is easily consumed by - * {@link Environment} users. If the app is running in Cloud Foundry then both meta data - * items are JSON objects encoded in OS environment variables. VCAP_APPLICATION is a - * shallow hash with basic information about the application (name, instance id, instance - * index, etc.), and VCAP_SERVICES is a hash of lists where the keys are service labels - * and the values are lists of hashes of service instance meta data. Examples are: - * - *
- * VCAP_APPLICATION: {"instance_id":"2ce0ac627a6c8e47e936d829a3a47b5b","instance_index":0,
- *   "version":"0138c4a6-2a73-416b-aca0-572c09f7ca53","name":"foo",
- *   "uris":["foo.cfapps.io"], ...}
- * VCAP_SERVICES: {"rds-mysql-1.0":[{"name":"mysql","label":"rds-mysql-1.0","plan":"10mb",
- *   "credentials":{"name":"d04fb13d27d964c62b267bbba1cffb9da","hostname":"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com",
- *   "host":"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com","port":3306,"user":"urpRuqTf8Cpe6",
- *   "username":"urpRuqTf8Cpe6","password":"pxLsGVpsC9A5S"}
- * }]}
- * 
- * - * These objects are flattened into properties. The VCAP_APPLICATION object goes straight - * to {@code vcap.application.*} in a fairly obvious way, and the VCAP_SERVICES object is - * unwrapped so that it is a hash of objects with key equal to the service instance name - * (e.g. "mysql" in the example above), and value equal to that instances properties, and - * then flattened in the same way. E.g. - * - *
- * vcap.application.instance_id: 2ce0ac627a6c8e47e936d829a3a47b5b
- * vcap.application.version: 0138c4a6-2a73-416b-aca0-572c09f7ca53
- * vcap.application.name: foo
- * vcap.application.uris[0]: foo.cfapps.io
- *
- * vcap.services.mysql.name: mysql
- * vcap.services.mysql.label: rds-mysql-1.0
- * vcap.services.mysql.credentials.name: d04fb13d27d964c62b267bbba1cffb9da
- * vcap.services.mysql.credentials.port: 3306
- * vcap.services.mysql.credentials.host: mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com
- * vcap.services.mysql.credentials.username: urpRuqTf8Cpe6
- * vcap.services.mysql.credentials.password: pxLsGVpsC9A5S
- * ...
- * 
- * - * N.B. this initializer is mainly intended for informational use (the application and - * instance ids are particularly useful). For service binding you might find that Spring - * Cloud is more convenient and more robust against potential changes in Cloud Foundry. - * - * @author Dave Syer - * @author Andy Wilkinson - * @deprecated since 1.3.0 in favor of CloudFoundryVcapEnvironmentPostProcessor - */ -@Deprecated -public class VcapEnvironmentPostProcessor - extends CloudFoundryVcapEnvironmentPostProcessor { - -} diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractConfigurableEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractConfigurableEmbeddedServletContainer.java index fe36e8e012f..24c8826e3f4 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractConfigurableEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractConfigurableEmbeddedServletContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -270,12 +270,6 @@ public abstract class AbstractConfigurableEmbeddedServletContainer this.registerDefaultServlet = registerDefaultServlet; } - @Override - public void setRegisterJspServlet(boolean registerJspServlet) { - Assert.notNull(this.jspServlet); - this.jspServlet.setRegistered(registerJspServlet); - } - /** * Flag to indicate that the default servlet should be registered. * @return true if the default servlet is to be registered @@ -293,12 +287,6 @@ public abstract class AbstractConfigurableEmbeddedServletContainer return this.ssl; } - @Override - public void setJspServletClassName(String jspServletClassName) { - Assert.notNull(this.jspServlet); - this.jspServlet.setClassName(jspServletClassName); - } - @Override public void setJspServlet(JspServlet jspServlet) { this.jspServlet = jspServlet; diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java index 94ccb039fcd..f3cfba84429 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -92,32 +92,6 @@ public interface ConfigurableEmbeddedServletContainer { */ void setAddress(InetAddress address); - /** - * The class name for the jsp servlet if used. If - * {@link #setRegisterJspServlet(boolean) registerJspServlet} is true and this - * class is on the classpath then it will be registered. Since both Tomcat and Jetty - * use Jasper for their JSP implementation the default is - * {@code org.apache.jasper.servlet.JspServlet}. - * @param jspServletClassName the class name for the JSP servlet if used - * @deprecated in 1.3.0 in favor of {@link JspServlet#setClassName(String)} - * @see #setJspServlet - * @see JspServlet#setClassName(String) - */ - @Deprecated - void setJspServletClassName(String jspServletClassName); - - /** - * Set if the JspServlet should be registered if it is on the classpath. Defaults to - * {@code true} so that files from the {@link #setDocumentRoot(File) document root} - * will be served. - * @param registerJspServlet if the JSP servlet should be registered - * @deprecated in 1.3.0 in favor of {@link JspServlet#setRegistered(boolean)} - * @see #setJspServlet - * @see JspServlet#setRegistered(boolean) - */ - @Deprecated - void setRegisterJspServlet(boolean registerJspServlet); - /** * Set if the DefaultServlet should be registered. Defaults to {@code true} so that * files from the {@link #setDocumentRoot(File) document root} will be served. diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java index 1ae19518dd7..bb63ed17499 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -45,8 +45,6 @@ public abstract class LoggingSystem { "org.springframework.boot.logging.logback.LogbackLoggingSystem"); systems.put("org.apache.logging.log4j.core.impl.Log4jContextFactory", "org.springframework.boot.logging.log4j2.Log4J2LoggingSystem"); - systems.put("org.apache.log4j.PropertyConfigurator", - "org.springframework.boot.logging.log4j.Log4JLoggingSystem"); systems.put("java.util.logging.LogManager", "org.springframework.boot.logging.java.JavaLoggingSystem"); SYSTEMS = Collections.unmodifiableMap(systems); @@ -69,20 +67,6 @@ public abstract class LoggingSystem { */ public void initialize(LoggingInitializationContext initializationContext, String configLocation, LogFile logFile) { - initialize(configLocation, logFile); - } - - /** - * Fully initialize the logging system. - * @param configLocation a log configuration location or {@code null} if default - * initialization is required - * @param logFile the log output file that should be written or {@code null} for - * console only output - * @deprecated since 1.3 in favor of - * {@link #initialize(LoggingInitializationContext, String, LogFile)} - */ - @Deprecated - public void initialize(String configLocation, LogFile logFile) { } /** @@ -110,8 +94,7 @@ public abstract class LoggingSystem { public abstract void setLogLevel(String loggerName, LogLevel level); /** - * Detect and return the logging system in use. Supports Logback, Log4J, Log4J2 and - * Java Logging. + * Detect and return the logging system in use. Supports Logback and Java Logging. * @param classLoader the classloader * @return The logging system */ diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/log4j/Log4JLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/log4j/Log4JLoggingSystem.java deleted file mode 100644 index cb6e954c91d..00000000000 --- a/spring-boot/src/main/java/org/springframework/boot/logging/log4j/Log4JLoggingSystem.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2012-2015 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.logging.log4j; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.log4j.Level; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; - -import org.springframework.boot.logging.LogFile; -import org.springframework.boot.logging.LogLevel; -import org.springframework.boot.logging.LoggingInitializationContext; -import org.springframework.boot.logging.LoggingSystem; -import org.springframework.boot.logging.Slf4JLoggingSystem; -import org.springframework.util.Assert; -import org.springframework.util.Log4jConfigurer; -import org.springframework.util.StringUtils; - -/** - * {@link LoggingSystem} for Log4j. - * - * @author Phillip Webb - * @author Dave Syer - * @author Andy Wilkinson - * @deprecated in Spring Boot 1.3 in favor of Apache Log4j 2 (following Apache's EOL - * declaration for log4j 1.x) - */ -@Deprecated -public class Log4JLoggingSystem extends Slf4JLoggingSystem { - - private static final Map LEVELS; - - static { - Map levels = new HashMap(); - levels.put(LogLevel.TRACE, Level.TRACE); - levels.put(LogLevel.DEBUG, Level.DEBUG); - levels.put(LogLevel.INFO, Level.INFO); - levels.put(LogLevel.WARN, Level.WARN); - levels.put(LogLevel.ERROR, Level.ERROR); - levels.put(LogLevel.FATAL, Level.FATAL); - levels.put(LogLevel.OFF, Level.OFF); - LEVELS = Collections.unmodifiableMap(levels); - } - - public Log4JLoggingSystem(ClassLoader classLoader) { - super(classLoader); - } - - @Override - protected String[] getStandardConfigLocations() { - return new String[] { "log4j.xml", "log4j.properties" }; - } - - @Override - public void beforeInitialize() { - super.beforeInitialize(); - LogManager.getRootLogger().setLevel(Level.FATAL); - } - - @Override - protected void loadDefaults(LoggingInitializationContext initializationContext, - LogFile logFile) { - if (logFile != null) { - loadConfiguration(getPackagedConfigFile("log4j-file.properties"), logFile); - } - else { - loadConfiguration(getPackagedConfigFile("log4j.properties"), logFile); - } - } - - @Override - protected void loadConfiguration(LoggingInitializationContext initializationContext, - String location, LogFile logFile) { - loadConfiguration(location, logFile); - } - - protected void loadConfiguration(String location, LogFile logFile) { - Assert.notNull(location, "Location must not be null"); - if (logFile != null) { - logFile.applyToSystemProperties(); - } - try { - Log4jConfigurer.initLogging(location); - } - catch (Exception ex) { - throw new IllegalStateException( - "Could not initialize Log4J logging from " + location, ex); - } - } - - @Override - protected void reinitialize(LoggingInitializationContext initializationContext) { - loadConfiguration(getSelfInitializationConfig(), null); - } - - @Override - public void setLogLevel(String loggerName, LogLevel level) { - Logger logger = (StringUtils.hasLength(loggerName) - ? LogManager.getLogger(loggerName) : LogManager.getRootLogger()); - logger.setLevel(LEVELS.get(level)); - } - - @Override - public Runnable getShutdownHandler() { - return new ShutdownHandler(); - } - - private static final class ShutdownHandler implements Runnable { - - @Override - public void run() { - LogManager.shutdown(); - } - - } - -} diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/log4j/package-info.java b/spring-boot/src/main/java/org/springframework/boot/logging/log4j/package-info.java deleted file mode 100644 index d5a91c83d58..00000000000 --- a/spring-boot/src/main/java/org/springframework/boot/logging/log4j/package-info.java +++ /dev/null @@ -1,20 +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. - */ - -/** - * Support for the Log4j logging library. - */ -package org.springframework.boot.logging.log4j; diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java index cb55e59dc6f..97ee14efdf6 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 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. @@ -195,7 +195,7 @@ public class LevelRemappingAppender extends AppenderBase { @Override @Deprecated public Map getMdc() { - return this.event.getMdc(); + return this.event.getMDCPropertyMap(); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/test/ServerPortInfoApplicationContextInitializer.java b/spring-boot/src/main/java/org/springframework/boot/test/ServerPortInfoApplicationContextInitializer.java deleted file mode 100644 index 988ce075d8d..00000000000 --- a/spring-boot/src/main/java/org/springframework/boot/test/ServerPortInfoApplicationContextInitializer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2012-2015 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.test; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.embedded.EmbeddedServletContainer; -import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext; -import org.springframework.context.ApplicationContextInitializer; -import org.springframework.core.env.Environment; - -/** - * {@link ApplicationContextInitializer} that sets {@link Environment} properties for the - * ports that {@link EmbeddedServletContainer} servers are actually listening on. The - * property {@literal "local.server.port"} can be injected directly into tests using - * {@link Value @Value} or obtained via the {@link Environment}. - *

- * If the {@link EmbeddedWebApplicationContext} has a - * {@link EmbeddedWebApplicationContext#setNamespace(String) namespace} set, it will be - * used to construct the property name. For example, the "management" actuator context - * will have the property name {@literal "local.management.port"}. - *

- * Properties are automatically propagated up to any parent context. - * - * @author Dave Syer - * @author Phillip Webb - * @deprecated since 1.3 in favor of - * org.springframework.boot.context.web.ServerPortInfoApplicationContextInitializer - */ -@Deprecated -public class ServerPortInfoApplicationContextInitializer extends - org.springframework.boot.context.web.ServerPortInfoApplicationContextInitializer { - -} diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file.properties deleted file mode 100644 index 5242f3d128f..00000000000 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file.properties +++ /dev/null @@ -1,32 +0,0 @@ -log4j.rootCategory=INFO, CONSOLE, FILE - -PID=???? -LOG_PATH=${java.io.tmpdir} -LOG_FILE=${LOG_PATH}/spring.log -LOG_LEVEL_PATTERN=%5p -LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${PID} ${LOG_LEVEL_PATTERN} [%t] --- %c{1}: %m%n - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN} - -log4j.appender.FILE=org.apache.log4j.RollingFileAppender -log4j.appender.FILE.File=${LOG_FILE} -log4j.appender.FILE.MaxFileSize=10MB -log4j.appender.FILE.layout = org.apache.log4j.PatternLayout -log4j.appender.FILE.layout.ConversionPattern=${LOG_PATTERN} - -log4j.category.org.apache.catalina.startup.DigesterFactory=ERROR -log4j.category.org.apache.catalina.util.LifecycleBase=ERROR -log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN -log4j.category.org.apache.sshd.common.util.SecurityUtils -log4j.category.org.apache.tomcat.util.net.NioSelectorPool=WARN -log4j.category.org.crsh.plugin=WARN -log4j.category.org.crsh.ssh=WARN -log4j.category.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR -log4j.category.org.hibernate.validator.internal.util.Version=WARN -log4j.category.org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration=WARN -log4j.category.org.springframework.boot.actuate.endpoint.jmx=WARN -log4j.category.org.thymeleaf=WARN - diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j.properties deleted file mode 100644 index a8769ee7a90..00000000000 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j.properties +++ /dev/null @@ -1,23 +0,0 @@ -log4j.rootCategory=INFO, CONSOLE - -PID=???? -LOG_LEVEL_PATTERN=%5p -LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${PID} ${LOG_LEVEL_PATTERN} [%t] --- %c{1}: %m%n - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN} - -log4j.category.org.apache.catalina.startup.DigesterFactory=ERROR -log4j.category.org.apache.catalina.util.LifecycleBase=ERROR -log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN -log4j.category.org.apache.sshd.common.util.SecurityUtils -log4j.category.org.apache.tomcat.util.net.NioSelectorPool=WARN -log4j.category.org.crsh.plugin=WARN -log4j.category.org.crsh.ssh=WARN -log4j.category.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR -log4j.category.org.hibernate.validator.internal.util.Version=WARN -log4j.category.org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration=WARN -log4j.category.org.springframework.boot.actuate.endpoint.jmx=WARN -log4j.category.org.thymeleaf=WARN diff --git a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index dec42064e9c..b65cd6ce2bf 100644 --- a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -177,24 +177,6 @@ public class SpringApplicationTests { verify(application, never()).printBanner((Environment) anyObject()); } - @SuppressWarnings("deprecation") - @Test - public void disableBannerWithBoolean() throws Exception { - SpringApplication application = spy(new SpringApplication(ExampleConfig.class)); - application.setWebEnvironment(false); - application.setShowBanner(false); - this.context = application.run(); - verify(application, never()).printBanner((Environment) anyObject()); - } - - @Test - public void disableBannerViaShowBannerProperty() throws Exception { - SpringApplication application = spy(new SpringApplication(ExampleConfig.class)); - application.setWebEnvironment(false); - this.context = application.run("--spring.main.show_banner=false"); - verify(application, never()).printBanner((Environment) anyObject()); - } - @Test public void disableBannerViaBannerModeProperty() throws Exception { SpringApplication application = spy(new SpringApplication(ExampleConfig.class)); diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java index eabd5480e90..51ec9ceb85b 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -499,11 +499,6 @@ public class LoggingApplicationListenerTests { } - @Override - public void initialize(String configLocation, LogFile logFile) { - - } - @Override public void setLogLevel(String loggerName, LogLevel level) { diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/log4j/Log4JLoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/log4j/Log4JLoggingSystemTests.java deleted file mode 100644 index 3fe02c46124..00000000000 --- a/spring-boot/src/test/java/org/springframework/boot/logging/log4j/Log4JLoggingSystemTests.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2012-2015 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.logging.log4j; - -import java.io.File; -import java.util.logging.Handler; -import java.util.logging.LogManager; - -import org.apache.commons.logging.impl.Log4JLogger; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.slf4j.bridge.SLF4JBridgeHandler; - -import org.springframework.boot.logging.AbstractLoggingSystemTests; -import org.springframework.boot.logging.LogLevel; -import org.springframework.boot.test.OutputCapture; -import org.springframework.util.StringUtils; - -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -/** - * Tests for {@link Log4JLoggingSystem}. - * - * @author Phillip Webb - * @author Andy Wilkinson - */ -@SuppressWarnings("deprecation") -public class Log4JLoggingSystemTests extends AbstractLoggingSystemTests { - - @Rule - public OutputCapture output = new OutputCapture(); - - private final Log4JLoggingSystem loggingSystem = new Log4JLoggingSystem( - getClass().getClassLoader()); - - private Log4JLogger logger; - - @Before - public void setup() { - this.logger = new Log4JLogger(getClass().getName()); - } - - @Override - @After - public void clear() { - this.loggingSystem.cleanUp(); - } - - @Test - public void noFile() throws Exception { - this.loggingSystem.beforeInitialize(); - this.logger.info("Hidden"); - this.loggingSystem.initialize(null, null, null); - this.logger.info("Hello world"); - String output = this.output.toString().trim(); - assertTrue("Wrong output:\n" + output, output.contains("Hello world")); - assertFalse("Output not hidden:\n" + output, output.contains("Hidden")); - assertFalse(new File(tmpDir() + "/spring.log").exists()); - } - - @Test - public void withFile() throws Exception { - this.loggingSystem.beforeInitialize(); - this.logger.info("Hidden"); - this.loggingSystem.initialize(null, null, getLogFile(null, tmpDir())); - this.logger.info("Hello world"); - String output = this.output.toString().trim(); - assertTrue("Wrong output:\n" + output, output.contains("Hello world")); - assertFalse("Output not hidden:\n" + output, output.contains("Hidden")); - assertTrue(new File(tmpDir() + "/spring.log").exists()); - } - - @Test - public void testNonDefaultConfigLocation() throws Exception { - this.loggingSystem.beforeInitialize(); - this.loggingSystem.initialize(null, "classpath:log4j-nondefault.properties", - getLogFile(null, tmpDir())); - this.logger.info("Hello world"); - String output = this.output.toString().trim(); - assertTrue("Wrong output:\n" + output, output.contains("Hello world")); - assertTrue("Wrong output:\n" + output, output.contains(tmpDir() + "/spring.log")); - assertFalse(new File(tmpDir() + "/tmp.log").exists()); - } - - @Test(expected = IllegalStateException.class) - public void testNonexistentConfigLocation() throws Exception { - this.loggingSystem.beforeInitialize(); - this.loggingSystem.initialize(null, "classpath:log4j-nonexistent.xml", null); - } - - @Test - public void setLevel() throws Exception { - this.loggingSystem.beforeInitialize(); - this.loggingSystem.initialize(null, null, null); - this.logger.debug("Hello"); - this.loggingSystem.setLogLevel("org.springframework.boot", LogLevel.DEBUG); - this.logger.debug("Hello"); - assertThat(StringUtils.countOccurrencesOf(this.output.toString(), "Hello"), - equalTo(1)); - } - - @Test - @Ignore("Fails on Bamboo") - public void loggingThatUsesJulIsCaptured() { - this.loggingSystem.beforeInitialize(); - this.loggingSystem.initialize(null, null, null); - java.util.logging.Logger julLogger = java.util.logging.Logger - .getLogger(getClass().getName()); - julLogger.severe("Hello world"); - String output = this.output.toString().trim(); - assertTrue("Wrong output:\n" + output, output.contains("Hello world")); - } - - @Test - public void bridgeHandlerLifecycle() { - assertFalse(bridgeHandlerInstalled()); - this.loggingSystem.beforeInitialize(); - assertTrue(bridgeHandlerInstalled()); - this.loggingSystem.cleanUp(); - assertFalse(bridgeHandlerInstalled()); - } - - private boolean bridgeHandlerInstalled() { - java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger(""); - Handler[] handlers = rootLogger.getHandlers(); - for (Handler handler : handlers) { - if (handler instanceof SLF4JBridgeHandler) { - return true; - } - } - return false; - } - -} diff --git a/spring-boot/src/test/resources/log4j-nondefault.properties b/spring-boot/src/test/resources/log4j-nondefault.properties deleted file mode 100644 index d852ca65d81..00000000000 --- a/spring-boot/src/test/resources/log4j-nondefault.properties +++ /dev/null @@ -1,10 +0,0 @@ -log4j.reset=true -log4j.rootCategory=INFO, CONSOLE - -PID=???? -LOG_PATTERN=${LOG_FILE} %d{yyyy-MM-dd HH:mm:ss.SSS}] service%X{context} - ${PID} %5p [%t] --- %c{1}: %m%n - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN}