I'm upgrading spring-boot to 2.6.2 and spring-cloud to 2021.0.0, and after upgrading, the brave.Tracer was not able to autowired in a @Configuration class.
The Tracer is autowired as parameter with @Bean component.
I have tried solutions in this question but doesn't work.
here is the @Configuration class:
@Configuration
@ConditionalOnWebApplication
@AutoConfigureAfter(CommonsAutoConfig.class)
@EnableConfigurationProperties({CorsConfig.class, TracingConfiguration.class})
public class WebCommonsAutoConfig
{
......
@Bean(name = "httpRestRequestResponseLogger")
@RefreshScope
public FilterRegistrationBean httpRestRequestResponseLogger(
RequestResponseLogger requestResponseLogger,
HeaderAccessor headerAccessor,
Tracer tracer,
HeaderExtractor<HttpServletRequestLoggingWrapper> httpHeaderExtractor)
{
final HttpLogFilter httpLogFilter= new HttpLogFilter(requestResponseLogger,
headerAccessor, tracer, httpHeaderExtractor);
final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(httpLogFilter);
registrationBean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE, REQUEST);
registrationBean.setOrder(HttpLogFilter.ORDER);
return registrationBean;
}
....
}
With the following error log:
...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'scopedTarget.httpRestRequestResponseLogger' defined in class
path resource [com/vzt/WebCommonsAutoConfig.class]: Unsatisfied dependency expressed
through method 'httpRestRequestResponseLogger' parameter 2;
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type 'brave.Tracer' available: expected at least 1 bean which
qualifies as autowire candidate. Dependency annotations: {}
So what shall I do to make the brave.Tracer autowired in this @Configuration class?