Allow TraceWebAutoConfiguration to work without Web MVC

Fixes #436
This commit is contained in:
Christoffer Sawicki
2016-11-06 20:03:34 +01:00
committed by Marcin Grzejszczak
parent b47bfe7fcb
commit cd2b0fd0f4

View File

@@ -40,6 +40,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import static javax.servlet.DispatcherType.ASYNC;
import static javax.servlet.DispatcherType.ERROR;
@@ -63,7 +64,6 @@ import static javax.servlet.DispatcherType.REQUEST;
@ConditionalOnBean(Tracer.class)
@AutoConfigureAfter(TraceAutoConfiguration.class)
@EnableConfigurationProperties(TraceKeys.class)
@Import(TraceWebMvcConfigurer.class)
public class TraceWebAutoConfiguration {
/**
@@ -72,6 +72,16 @@ public class TraceWebAutoConfiguration {
@Value("${spring.sleuth.web.skipPattern:}")
private String skipPattern;
/**
* Nested config that configures Web MVC if it's present
* (without adding a runtime dependency to it)
*/
@Configuration
@ConditionalOnClass(WebMvcConfigurerAdapter.class)
@Import(TraceWebMvcConfigurer.class)
protected static class TraceWebMvcAutoConfiguration {
}
@Bean
public TraceWebAspect traceWebAspect(Tracer tracer, SpanNamer spanNamer) {
return new TraceWebAspect(tracer, spanNamer);