Closed as not planned
Description
Spring Boot Version
2.6.0+
How to Reproduce
Implments MeterBinder
and inject RedisTemplate
@Service
public class InMemoryUserRegistrationService implements UserRegistrationService, MeterBinder {
@Autowired
private RedisTemplate redisTemplate;
@Override
public void bindTo(MeterRegistry registry) {
}
}
Then I just launch the application, and Circular-References are created
Errors Output
***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
webMvcMetricsFilter defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]
┌─────┐
| prometheusMeterRegistry defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]
↑ ↓
| userRegistrationService (field private org.springframework.data.redis.core.RedisTemplate com.xxx.biz.web.service.InMemoryUserRegistrationService.redisTemplate)
↑ ↓
| redisTemplate defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class]
↑ ↓
| redisConnectionFactory defined in class path resource [org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]
↑ ↓
| lettuceClientResources defined in class path resource [org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]
↑ ↓
| lettuceMetrics defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/redis/LettuceMetricsAutoConfiguration.class]
└─────┘
Action:
Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
I ended up having RedisTemplate injected into my business code using @Lazy