java.lang.NoClassDefFoundError:org/springframework/core/NativeDetector [英] java.lang.NoClassDefFoundError: org/springframework/core/NativeDetector
本文介绍了java.lang.NoClassDefFoundError:org/springframework/core/NativeDetector的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm brushing up on spring with this tutorial and getting the following dependency issue on 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
类是这样的:
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()
}
非常感谢任何对此问题有知识的人!
Many thanks to anyone with any knowledge about this issue!
推荐答案
Based on https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/ you should use spring boot 2.4.3. Thanks @Jens Schauder.
这篇关于java.lang.NoClassDefFoundError:org/springframework/core/NativeDetector的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文