Issue
I upgraded spring.version from 5.0.18.RELEASE to 5.3.21
and spring.boot.version from 2.1.18.RELEASE to 2.7.0
spring-boot-starter-actuator ${spring.boot.version}
In my Healthcheck class I use:
@Autowired private MetricsEndpoint metrics;
After upgrade I've got:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthcheck':
Unsatisfied dependency expressed through field 'metrics'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'org.springframework.boot.actuate.metrics.MetricsEndpoint' available:
expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Why Spring doesn't see org.springframework.boot.actuate.metrics.MetricsEndpoint ?
Solution
2.1.18.RELEASE to 2.7.0 is an enormous jump, so as the comment says I'd suggest checking the upgrade guide carefully.
Nonetheless, you need to expose the metrics endpoint in your config, which will create the bean.
management.endpoints.web.exposure.include: metrics
Answered By - Matt
Answer Checked By - Willingham (JavaFixing Volunteer)