Spring数据mongodb中的异常-由以下原因引起:java.lang.ClassNotFoundException:org.bson.types.Decimal128

时间:2019-10-03 03:29:35

标签: spring-boot mongodb-query spring-data-mongodb

我在春季启动中有一个项目,使用mongodb作为数据库,并且正在使用spring-data-mongo。

为了使用spring数据运行排序查询(无需创建单独的mongo模板),例如-

 @Query(sort = "{ productName : -1 }")
 List<Product> findByProductNameLike(String regularExpression);

我将依赖关系更新为2.2.0版

 <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-mongodb</artifactId>
        <version>2.2.0.RELEASE</version>
 </dependency> 

但是我遇到了这个无法解决的异常。 我刚刚更改了版本,知道吗?还可以在不创建mongo模板的情况下进行排序吗?

 org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/home/abc/.m2/repository/org/springframework/data/spring-data-mongodb/2.2.0.RELEASE/spring-data-mongodb-2.2.0.RELEASE.jar!/org/springframework/data/mongodb/core/mapping/MongoId.class]; nested exception is java.lang.NoClassDefFoundError: org/bson/types/Decimal128
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:303) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.data.web.config.EnableSpringDataWebSupport$SpringDataWebConfigurationImportSelector.selectImports(EnableSpringDataWebSupport.java:133) ~[spring-data-commons-1.12.2.RELEASE.jar:na]
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:518) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:286) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:237) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:537) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:482) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:191) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at com.abcd.prodcat.application.Application.main(Application.java:15) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.4.0.RELEASE.jar:1.4.0.RELEASE]
Caused by: java.lang.NoClassDefFoundError: org/bson/types/Decimal128
at org.springframework.data.mongodb.core.mapping.FieldType.<clinit>(FieldType.java:58) ~[spring-data-mongodb-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
at java.lang.Class.getEnumConstantsShared(Class.java:3320) ~[na:1.8.0_161]
at java.lang.Class.enumConstantDirectory(Class.java:3341) ~[na:1.8.0_161]
at java.lang.Enum.valueOf(Enum.java:232) ~[na:1.8.0_161]
at sun.reflect.annotation.AnnotationParser.parseEnumValue(AnnotationParser.java:483) ~[na:1.8.0_161]
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:347) ~[na:1.8.0_161]
at java.lang.reflect.Method.getDefaultValue(Method.java:606) ~[na:1.8.0_161]
at org.springframework.core.annotation.AnnotationUtils.registerDefaultValues(AnnotationUtils.java:1168) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(RecursiveAnnotationAttributesVisitor.java:42) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:64) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1802) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.asm.ClassReader.accept(ClassReader.java:642) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.asm.ClassReader.accept(ClassReader.java:508) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:279) ~[spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
... 25 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.bson.types.Decimal128
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_161]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_161]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_161]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_161]
... 46 common frames omitted

0 个答案:

没有答案