I am updating spring-boot-dependency version from 2.3.0 to 2.7.16 but when i try to run the application i was facing below error:

Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'simpleMeterRegistry' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/metrics/export/
simple/SimpleMetricsExportAutoConfiguration.class]: 
Initialization of bean failed; nested exception is 
java.lang.NoClassDefFoundError: 
io/micrometer/core/instrument/binder/system/DiskSpaceMetrics

I have versions
spring-boot-dependecies version: 2.7.16
micrometer version: 1.5.1
spring-cloud-dependencies version: 2021.0.0

1

There are 1 best solutions below

0
On BEST ANSWER

Spring Boot version 2.17.6 by default should be using micrometer version 1.9.15 SpringBoot 2.7.16 dependencies. With the micrometer transition from 1.7 to 1.8 the package for DiskSpaceMetrics changed. Most likely you have a library within your project that is pulling in an earlier version of micrometer.

Add an explicit dependency to micrometer-core and see if this resoolves your issue.

Maven:

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-core</artifactId>
    <version>1.9.15</version>
</dependency>

Also make sure you do not have a spring-boot-actuator version explicitly set to something earlier than version 2.7.16. You may also want to investigate your dependency tree where you can exam possibly the source of an earlier version of micrometer being pulled in.

mvn dependency:tree