1

Getting the below Exception while trying to upgrade to spring boot version 2.7.11 fro existing Spring Boot version 2.2.6.RELEASE

Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'prometheusMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.micrometer.prometheus.PrometheusMeterRegistry]: Factory method 'prometheusMeterRegistry' threw exception; nested exception is java.lang.NoSuchMethodError: 'void io.micrometer.prometheus.PrometheusMeterRegistry.<init>(io.micrometer.prometheus.PrometheusConfig, io.prometheus.client.CollectorRegistry, io.micrometer.core.instrument.Clock, io.prometheus.client.exemplars.ExemplarSampler)'

Upgrade should work seamlessly from spring Boot version 2.2.6.RELEASE to Spring Boot version 2.7.11. However Prometheus is continuously failing . I have below configuration

compile("org.springframework.boot:spring-boot-starter-actuator")

    // https://mvnrepository.com/artifact/io.prometheus/simpleclient
    implementation group: 'io.prometheus', name: 'simpleclient', version: '0.16.0'

    // https://mvnrepository.com/artifact/io.prometheus.jmx/collector
    implementation group: 'io.prometheus.jmx', name: 'collector', version: '0.18.0'

// https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus
    implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.11.0'

Existing Configuration 2.2.2.RELEASE

implementation group: 'org.springframework', name: 'spring-aspects', version: '5.3.27' implementation group: 'org.springframework', name: 'spring-core', version: '5.3.27' implementation group: 'org.springframework', name: 'spring-beans', version: '5.3.27' compile("org.springframework.boot:spring-boot-starter-actuator") implementation group: 'io.micrometer', name: 'micrometer-core', version: '1.5.5'

  • Can you provide your previous configuration you using. It seems miss match version. – Dhaval Gajjar May 20 '23 at 06:15
  • Configuration looks like ` implementation group: 'org.springframework', name: 'spring-aspects', version: '5.3.27' implementation group: 'org.springframework', name: 'spring-core', version: '5.3.27' implementation group: 'org.springframework', name: 'spring-beans', version: '5.3.27' compile("org.springframework.boot:spring-boot-starter-actuator") implementation group: 'io.micrometer', name: 'micrometer-core', version: '1.5.5'` – jatin mahajan May 21 '23 at 10:53
  • @jatinmahajan, comments are a wrong place for this kind of information. In general if you have something for the question, [edit] it and add desired information there (using appropriate formatting). – markalex May 21 '23 at 20:36
  • 1
    Verify the dependency tree, and make sure there are no multiple instances of `micrometer-registry-prometheus`. The constructor mentioned exists since version `1.9.0` and version `1.11.0` still has it – Jhilton May 22 '23 at 05:25

1 Answers1

1

You should delete all of your version definitions and let the Spring Boot BOM define versions for you, this is what you need:

implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'

Also, mvnrepository is not the official repo we publish our artifacts, that's Maven Central.

Jonatan Ivanov
  • 4,895
  • 2
  • 15
  • 30