Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup

2024-04-04

我目前正在做一些概念验证工作春季启动 and GCP数据存储.

My pom.xml

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <version>2.4.0</version>
</dependency>

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-gcp-data-datastore</artifactId>
  <version>1.2.6.RELEASE</version>
</dependency>

问题:Spring Boot 无法启动

当我尝试启动该应用程序时,我得到:

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/metrics/ApplicationStartup
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:251)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:264)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)

我尝试过的

我尝试添加Actuator依赖性。 但这并没有达到目的。 我无法弄清楚我缺少什么依赖性。我看到了类定义here https://docs.spring.io/spring-framework/docs/5.3.0-M2/javadoc-api/index.html?org/springframework/core/metrics/ApplicationStartup.html在 5.3.0-M2 文档中,但我不确定它存在于什么依赖项中。

我还尝试添加以下指标依赖项:

  • spring-cloud-gcp-starter-metrics
  • 弹簧度量
  • spring-cloud-stream-metrics 弹簧云流指标

我搜索了没有运气。

如果可能的话,我也不介意禁用它。


Update:

I added:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>5.3.1</version>
</dependency>

这给了我一个新的错误:

尝试调用不存在的方法。尝试 是从以下位置制作的:

org.springframework.boot.SpringApplication.run(SpringApplication.java:324)

以下方法不存在:

'void org.springframework.context.ConfigurableApplicationContext.setApplicationStartup(org.springframework.core.metrics.ApplicationStartup)'

该方法的类, org.springframework.context.ConfigurableApplicationContext,是 可从以下地点获取:

... 行动:

更正应用程序的类路径,使其包含 单一兼容版本 org.springframework.context.ConfigurableApplicationContext


我能够通过降级 Spring Boot 来解决这个问题:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <version>2.3.3.RELEASE</version>
</dependency>

猜猜它还与 2.4.0 不兼容。

具体来说,我还必须确保我使用的是 2.3.3.RELEASE,而不是由于我遇到的其他问题而更新的版本。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup 的相关文章

随机推荐