簡體   English   中英

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

[英]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

UserPersistence class 是這樣的:

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> {}

我正在使用這個build.gradle

plugins {
    id 'org.springframework.boot' version '2.3.9.RELEASE'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'org.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    implementation group: 'org.springframework.data', name: 'spring-data-commons', version: '2.4.5'
    implementation group: 'com.querydsl', name: 'querydsl-jpa', version: '4.4.0'
    implementation group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
    implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'com.h2database:h2'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}

非常感謝任何對此問題有任何了解的人!

基於https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/你應該使用 Z2A2D595E6ED9A0B24F027F2B63B134D6.Z 引導。 謝謝@Jens Schauder。

當我將 spring 核心版本更改為 5.3.8 時,它對我有用

我在我的 pom.xml 中更新了以下條目

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM