gpt4 book ai didi

spring-boot - Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup

转载 作者:行者123 更新时间:2023-12-03 13:34:04 30 4
gpt4 key购买 nike

我目前正在Spring Boot和GCP数据存储中进行一些概念验证工作。
在我的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>
当我尝试启动该应用程序时,我得到:
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)
我尝试添加执行器,但并没有解决问题,但是我无法弄清缺少的依赖项。我在5.3.0-M2文档中看到了类定义 here,但是我不确定它存在什么依赖性。
我也尝试添加:
  • spring-cloud-gcp-starter-metrics
  • spring-metrics
  • spring-cloud-stream-metrics

  • 我在 findjar.com中搜索失败了。
    如果可以的话,我也不会禁用它。

    更新:
    我补充说:
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.3.1</version>
    </dependency>
    这给了我一个新的错误:

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

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

    The following method did not exist:

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

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

    ...Action:

    Correct the classpath of your application so that it contains asingle, compatible version oforg.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,而不是由于遇到其他问题而更新的版本。

    关于spring-boot - Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65046056/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com