我已经使用这个 jar 将 redis 与 micronaut 集成。 编译'io.micronaut.configuration:micronaut-redis-lettuce' 默认情况下,即使我在我的 micronaut 应用程序中禁用了健康端点,也会启用 redis 健康检查。 https://micronaut-projects.github.io/micronaut-redis/latest/guide/
下面是我每 100 秒得到的异常,因为我将健康间隔配置为 micronaut.health.monitor.interval:100s
Path Taken: new HealthMonitorTask(CurrentHealthStatus currentHealthStatus,[List healthIndicators]) --> new RedisHealthIndicator(BeanContext beanContext,[HealthAggregator healthAggregator],StatefulRedisConnection[] connections)
io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for parameter [healthAggregator] of class: io.micronaut.configuration.lettuce.health.RedisHealthIndicator
Message: No bean of type [io.micronaut.management.health.aggregator.HealthAggregator] exists. Make sure the bean is not disabled by bean requirements (enable trace logging for 'io.micronaut.context.condition' to check) and if the bean is enabled then ensure the class is declared a bean and annotation processing is enabled (for Java and Kotlin the 'micronaut-inject-java' dependency should be configured as an annotation processor).
Path Taken: new HealthMonitorTask(CurrentHealthStatus currentHealthStatus,[List healthIndicators]) --> new RedisHealthIndicator(BeanContext beanContext,[HealthAggregator healthAggregator],StatefulRedisConnection[] connections)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:990)
at io.micronaut.configuration.lettuce.health.$RedisHealthIndicatorDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1494)
at io.micronaut.context.DefaultBeanContext.addCandidateToList(DefaultBeanContext.java:2507)
at io.micronaut.context.DefaultBeanContext.getBeansOfTypeInternal(DefaultBeanContext.java:2429)
at io.micronaut.context.DefaultBeanContext.getBeansOfType(DefaultBeanContext.java:854)
at io.micronaut.context.AbstractBeanDefinition.lambda$getBeansOfTypeForConstructorArgument$10(AbstractBeanDefinition.java:1088)
at io.micronaut.context.AbstractBeanDefinition.resolveBeanWithGenericsFromConstructorArgument(AbstractBeanDefinition.java:1697)
at io.micronaut.context.AbstractBeanDefinition.getBeansOfTypeForConstructorArgument(AbstractBeanDefinition.java:1083)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:962)```
最佳答案
在 application.properties 中将此参数设置为 false 即可解决。
micronaut.health.monitor.enabled=false
关于redis - redis-lettuce 与 micronaut 集成时如何禁用 Redis 健康检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57477997/