Spring Boot-Spring Boot启动器执行器问题

问题描述 投票:0回答:1

因此,我正在创建一个新的spring boot项目,并希望使用spring-boot-starter-actuator。但是,启动应用程序时我遇到了问题。

Pom代码段:

      <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <!--<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

<spring-boot.version>2.2.0.RELEASE</spring-boot.version>

spring-boot s在我的类路径中:enter image description here

启动应用程序时出错:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration.bindEntityManagerFactoryToRegistry(HibernateMetricsAutoConfiguration.java:68)

The following method did not exist:

    io.micrometer.core.instrument.binder.jpa.HibernateMetrics.<init>(Lorg/hibernate/SessionFactory;Ljava/lang/String;Ljava/lang/Iterable;)V

The method's class, io.micrometer.core.instrument.binder.jpa.HibernateMetrics, is available from the following locations:

    jar:file:/C:/Users/rahul/.m2/repository/io/micrometer/micrometer-core/1.0.2/micrometer-core-1.0.2.jar!/io/micrometer/core/instrument/binder/jpa/HibernateMetrics.class

It was loaded from the following location:

    file:/C:/Users/rahul/.m2/repository/io/micrometer/micrometer-core/1.0.2/micrometer-core-1.0.2.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of io.micrometer.core.instrument.binder.jpa.HibernateMetrics

此时发生例外:enter image description here

但是,只有HibernateMetrics的一个构造函数看起来像这样:

public HibernateMetrics(EntityManagerFactory entityManagerFactory, String entityManagerFactoryName, Iterable<Tag> tags) {
        this.tags = Tags.concat(tags, "entityManagerFactory", entityManagerFactoryName);
        this.stats = hasStatisticsEnabled(entityManagerFactory) ? getStatistics(entityManagerFactory) : null;
    }

从依赖关系分析器中,可以看到micrometer-core没有多个版本:enter image description here

我也尝试过spring-boot-starter-actuator version of 2.2.0.RELEASE,但是有相同的问题。

我不确定我在这里想念的是什么,我们将不胜感激。

java spring spring-boot spring-boot-actuator
1个回答
0
投票

假定您将spring-boot-actuator应用程序与JMX控制台连接。 (“因为它不是Web应用程序”)

我已经将Spring Initializr与您的pom依赖关系和一个CommandLineRunner示例一起使用。 Github示例:https://github.com/thiagochagas/actuator-example

© www.soinside.com 2019 - 2024. All rights reserved.