Use Spring Framework bom and fully exclude commons-logging
Closes #955 Closes #978
This commit is contained in:
parent
6fbafc3ca4
commit
7a8be3d600
|
|
@ -16,14 +16,15 @@
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.logging;
|
package org.springframework.boot.autoconfigure.logging;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogConfigurationException;
|
import org.apache.commons.logging.LogConfigurationException;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.commons.logging.impl.LogFactoryImpl;
|
|
||||||
import org.apache.commons.logging.impl.NoOpLog;
|
import org.apache.commons.logging.impl.NoOpLog;
|
||||||
|
import org.apache.commons.logging.impl.SLF4JLogFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -41,6 +42,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.event.ContextRefreshedEvent;
|
import org.springframework.context.event.ContextRefreshedEvent;
|
||||||
import org.springframework.mock.web.MockServletContext;
|
import org.springframework.mock.web.MockServletContext;
|
||||||
|
import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
|
@ -71,6 +73,10 @@ public class AutoConfigurationReportLoggingInitializerTests {
|
||||||
|
|
||||||
protected List<String> infoLog = new ArrayList<String>();
|
protected List<String> infoLog = new ArrayList<String>();
|
||||||
|
|
||||||
|
private Field logFactoryField;
|
||||||
|
|
||||||
|
private LogFactory originalLogFactory;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
setupLogging(true, true);
|
setupLogging(true, true);
|
||||||
|
|
@ -98,15 +104,25 @@ public class AutoConfigurationReportLoggingInitializerTests {
|
||||||
}
|
}
|
||||||
}).given(this.log).info(anyObject());
|
}).given(this.log).info(anyObject());
|
||||||
|
|
||||||
LogFactory.releaseAll();
|
try {
|
||||||
System.setProperty(LogFactory.FACTORY_PROPERTY, MockLogFactory.class.getName());
|
this.logFactoryField = LogFactory.class.getDeclaredField("logFactory");
|
||||||
|
ReflectionUtils.makeAccessible(this.logFactoryField);
|
||||||
|
|
||||||
|
this.originalLogFactory = (LogFactory) ReflectionUtils.getField(
|
||||||
|
this.logFactoryField, null);
|
||||||
|
|
||||||
|
ReflectionUtils.setField(this.logFactoryField, null, new MockLogFactory());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new IllegalStateException("Failed to set logFactory", e);
|
||||||
|
}
|
||||||
|
|
||||||
this.initializer = new AutoConfigurationReportLoggingInitializer();
|
this.initializer = new AutoConfigurationReportLoggingInitializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
System.clearProperty(LogFactory.FACTORY_PROPERTIES);
|
ReflectionUtils.setField(this.logFactoryField, null, this.originalLogFactory);
|
||||||
LogFactory.releaseAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -199,7 +215,7 @@ public class AutoConfigurationReportLoggingInitializerTests {
|
||||||
containsString("Unable to provide auto-configuration report"));
|
containsString("Unable to provide auto-configuration report"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MockLogFactory extends LogFactoryImpl {
|
public static class MockLogFactory extends SLF4JLogFactory {
|
||||||
@Override
|
@Override
|
||||||
public Log getInstance(String name) throws LogConfigurationException {
|
public Log getInstance(String name) throws LogConfigurationException {
|
||||||
if (AutoConfigurationReportLoggingInitializer.class.getName().equals(name)) {
|
if (AutoConfigurationReportLoggingInitializer.class.getName().equals(name)) {
|
||||||
|
|
|
||||||
|
|
@ -104,17 +104,22 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.aether</groupId>
|
<groupId>org.eclipse.aether</groupId>
|
||||||
<artifactId>aether-transport-http</artifactId>
|
<artifactId>aether-transport-http</artifactId>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>jcl-over-slf4j</artifactId>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.aether</groupId>
|
<groupId>org.eclipse.aether</groupId>
|
||||||
<artifactId>aether-util</artifactId>
|
<artifactId>aether-util</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Runtime -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-nop</artifactId>
|
||||||
|
<version>1.7.7</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
<!-- Provided -->
|
<!-- Provided -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.groovy</groupId>
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
|
|
|
||||||
|
|
@ -474,6 +474,12 @@
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
<artifactId>velocity-tools</artifactId>
|
<artifactId>velocity-tools</artifactId>
|
||||||
<version>${velocity-tools.version}</version>
|
<version>${velocity-tools.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.aspectj</groupId>
|
<groupId>org.aspectj</groupId>
|
||||||
|
|
@ -594,6 +600,12 @@
|
||||||
<groupId>org.crashub</groupId>
|
<groupId>org.crashub</groupId>
|
||||||
<artifactId>crash.connectors.ssh</artifactId>
|
<artifactId>crash.connectors.ssh</artifactId>
|
||||||
<version>${crashub.version}</version>
|
<version>${crashub.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.crashub</groupId>
|
<groupId>org.crashub</groupId>
|
||||||
|
|
@ -804,111 +816,22 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-aop</artifactId>
|
<artifactId>spring-framework-bom</artifactId>
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-aspects</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-beans</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-context</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-context-support</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
<version>${spring.version}</version>
|
||||||
|
<scope>import</scope>
|
||||||
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-core</artifactId>
|
||||||
<version>${spring.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-expression</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-instrument</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-jdbc</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-jms</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-messaging</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-orm</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-oxm</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>commons-lang</groupId>
|
|
||||||
<artifactId>commons-lang</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-test</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-tx</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-web</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-webmvc</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-webmvc-portlet</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-websocket</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>springloaded</artifactId>
|
<artifactId>springloaded</artifactId>
|
||||||
|
|
@ -968,6 +891,21 @@
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.integration</groupId>
|
||||||
|
<artifactId>spring-integration-http</artifactId>
|
||||||
|
<version>${spring-integration.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.mobile</groupId>
|
<groupId>org.springframework.mobile</groupId>
|
||||||
<artifactId>spring-mobile-device</artifactId>
|
<artifactId>spring-mobile-device</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,12 @@
|
||||||
<requireJavaVersion>
|
<requireJavaVersion>
|
||||||
<version>1.7</version>
|
<version>1.7</version>
|
||||||
</requireJavaVersion>
|
</requireJavaVersion>
|
||||||
|
<bannedDependencies>
|
||||||
|
<excludes>
|
||||||
|
<exclude>commons-logging:commons-logging:*:compile</exclude>
|
||||||
|
</excludes>
|
||||||
|
<searchTransitive>true</searchTransitive>
|
||||||
|
</bannedDependencies>
|
||||||
</rules>
|
</rules>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ import ch.qos.logback.classic.Level;
|
||||||
public class LogbackInitializer {
|
public class LogbackInitializer {
|
||||||
|
|
||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
if (ClassUtils.isPresent("org.slf4j.impl.StaticLoggerBinder", null)) {
|
if (ClassUtils.isPresent("org.slf4j.impl.StaticLoggerBinder", null)
|
||||||
|
&& ClassUtils.isPresent("ch.qos.logback.classic.Logger", null)) {
|
||||||
new Initializer().setRootLogLevel();
|
new Initializer().setRootLogLevel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Compile -->
|
<!-- Compile -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-core</artifactId>
|
||||||
|
|
@ -150,11 +154,6 @@
|
||||||
<artifactId>spring-webmvc</artifactId>
|
<artifactId>spring-webmvc</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>jcl-over-slf4j</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue