Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup [英] Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup

查看:480
本文介绍了Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在 Spring Boot 和 GCP 数据存储方面进行一些概念验证工作.

I am currently playing with some proof-of-concept work in Spring Boot and GCP data storage.

在我的 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>

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

When I attempt to launch the application, I get:

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)

我尝试添加执行器,但没有成功,但我无法弄清楚我缺少什么依赖项.我看到类定义 here 在 5.3.0-M2 文档中,但我不确定它存在于什么依赖项中.

I tried adding Actuator and that did not do the trick, but I cannot figure out what dependency I am missing. I see the class definition here in 5.3.0-M2 documentation, but I'm not sure what dependency it exists in.

我也尝试添加:

  • spring-cloud-gcp-starter-metrics
  • 弹簧指标
  • spring-cloud-stream-metrics

我在 findjar.com 运气不好.

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

I wouldn't mind disabling it as well if that is possible.

更新:

我补充说:

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

这给了我一个新的错误:

Which gives me a new error:

尝试调用不存在的方法.尝试来自以下位置:

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

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

以下方法不存在:

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

方法的类,org.springframework.context.ConfigurableApplicationContext,是可从以下位置获得:

The method's class, org.springframework.context.ConfigurableApplicationContext, is available from the following locations:

...行动:

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

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.context.ConfigurableApplicationContext

推荐答案

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

I was able to solve this by downgrading Spring Boot:

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

猜测它只是不兼容 2.4.0.

Guess it's just not compatible with 2.4.0 yet.

特别是我还必须确保我使用的是 2.3.3.RELEASE 而不是由于我遇到的其他问题而使用的最新版本.

Specifically I also had to ensure that I used 2.3.3.RELEASE and not anything more recent due to other issues I ran across.

这篇关于Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆