Spring 启动 - Spring 启动启动器执行器出现问题
Spring Boot - Issue with Spring Boot Starter Actuator
所以我正在创建一个新的 spring 引导项目并想尝试使用 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 在我的类路径上:
启动应用程序时出错:
***************************
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
此时出现异常:
然而 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
没有多个版本:
我也尝试过 spring-boot-starter-actuator version of 2.2.0.RELEASE
,但它有同样的问题。
我不确定我在这里遗漏了什么,非常感谢任何帮助。
假设您将 spring-boot-actuator 应用程序连接到 JMX 控制台。 ("because it's not a web application")
我根据您的 pom 依赖项和 CommandLine运行ner 示例使用了 Spring Initializr。 Github 示例:https://github.com/thiagochagas/actuator-example
调整:
我删除了 "spring-boot-starter" 依赖项:
<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>
我在 DemoApplication class 中使用了 Thread.sleep(30000L) 来简化示例。
安装并运行应用程序:
./mvnw clean install
java -jar target/demo-0.0.1-SNAPSHOT.jar
打开 jconsole:
$JAVA_HOME/bin/jconsole
虽然您的应用程序 运行 它应该在 jconsole 上。
Select 你的"demo-0.0.1-SNAPSHOT.jar" 分析一下:
如果显示此消息,select 选项 "Insecure Connection":
运行应用分析:
所以我正在创建一个新的 spring 引导项目并想尝试使用 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 在我的类路径上:
启动应用程序时出错:
***************************
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
此时出现异常:
然而 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
没有多个版本:
我也尝试过 spring-boot-starter-actuator version of 2.2.0.RELEASE
,但它有同样的问题。
我不确定我在这里遗漏了什么,非常感谢任何帮助。
假设您将 spring-boot-actuator 应用程序连接到 JMX 控制台。 ("because it's not a web application")
我根据您的 pom 依赖项和 CommandLine运行ner 示例使用了 Spring Initializr。 Github 示例:https://github.com/thiagochagas/actuator-example
调整: 我删除了 "spring-boot-starter" 依赖项:
<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>
我在 DemoApplication class 中使用了 Thread.sleep(30000L) 来简化示例。
安装并运行应用程序:
./mvnw clean install
java -jar target/demo-0.0.1-SNAPSHOT.jar
打开 jconsole:
$JAVA_HOME/bin/jconsole
虽然您的应用程序 运行 它应该在 jconsole 上。
Select 你的"demo-0.0.1-SNAPSHOT.jar" 分析一下:
如果显示此消息,select 选项 "Insecure Connection":
运行应用分析: