相关疑难解决方法(0)

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

我目前正在 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>
Run Code Online (Sandbox Code Playgroud)

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

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)
Run Code Online (Sandbox Code Playgroud)

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

我也尝试添加:

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

我在findjar.com 中搜索,没有运气。

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


更新:

我补充说:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>5.3.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

这给了我一个新的错误:

试图调用不存在的方法。尝试是从以下位置进行的:

org.springframework.boot.SpringApplication.run(SpringApplication.java:324)
Run Code Online (Sandbox Code Playgroud)

以下方法不存在:

'void org.springframework.context.ConfigurableApplicationContext.setApplicationStartup(org.springframework.core.metrics.ApplicationStartup)'
Run Code Online (Sandbox Code Playgroud)

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

... 行动:

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

spring-boot

10
推荐指数
1
解决办法
3万
查看次数

java.lang.NoClassDefFoundError: org/springframework/core/NativeDetector

我正在通过本教程温习 Spring ,并在 JPARepository 上遇到以下依赖问题:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userPersistence' defined in persistence.UserPersistence defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/NativeDetector
Run Code Online (Sandbox Code Playgroud)

UserPersistence是这样的:

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;


@RepositoryRestResource()
public interface UserPersistence extends JpaRepository<UserDAO, Integer>, JpaSpecificationExecutor<UserDAO>, QuerydslPredicateExecutor<UserDAO> {}
Run Code Online (Sandbox Code Playgroud)

我正在使用这个build.gradle

plugins {
    id …
Run Code Online (Sandbox Code Playgroud)

java spring gradle spring-data spring-data-jpa

7
推荐指数
2
解决办法
2万
查看次数