简体   繁体   English

Spring Boot MongoDB 中的 org.springframework.data.mongodb.UncategorizedMongoDbException 异常

[英]org.springframework.data.mongodb.UncategorizedMongoDbException Exception in Spring Boot MongoDB

Cannot understand why this exception is happening无法理解为什么会发生此异常

org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "Book" }' on server localhost:27017; nested exception is com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'Field 'locale' is invalid in: { locale: "Book" }' on server localhost:27017
    at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:140)
    at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2899)
    at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:2824)
    at org.springframework.data.mongodb.core.MongoTemplate.findAll(MongoTemplate.java:1779)
    at org.springframework.data.mongodb.core.MongoTemplate.findAll(MongoTemplate.java:1774)
    at com.aditya.books.repository.CustomBookRepository.findAll(CustomBookRepository.java:18)
    at com.aditya.books.repository.CustomBookRepository$$FastClassBySpringCGLIB$$66917159.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)
    at com.aditya.books.repository.CustomBookRepository$$EnhancerBySpringCGLIB$$2414047e.findAll(<generated>)

Book Model书型

public class Book {
    @Id
    @JsonProperty(value = "bookID")
    private long id;
    private String title;
    private String authors;
    private String average_rating;
    private String isbn;
    private String language_code;
    private String ratings_count;
    private String price;
}

This is happening when I am calling findAll method from MongoRepository.当我从 MongoRepository 调用 findAll 方法时会发生这种情况。 I have checked data in DB also and everything seems fine and there is no field with name 'locale'我也检查了数据库中的数据,一切似乎都很好,并且没有名称为“locale”的字段

NVM , I found the error I was using NVM ,我发现了我使用的错误

@Document(collation= "Book")

instead of代替

@Document(collection = "Book")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 名称为“ org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory”的bean:QueryDSL MongoDb - bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' exception: QueryDSL MongoDb Spring-Data-Mongo 1.7:org.springframework.data.mongodb.LazyLoadingException无法延迟解析DBRef - Spring-Data-Mongo 1.7: org.springframework.data.mongodb.LazyLoadingException Unable to lazily resolve DBRef Mongock 失败:NoClassDefFoundError org/springframework/data/mongodb/MongoDatabaseFactory - Mongock failed: NoClassDefFoundError org/springframework/data/mongodb/MongoDatabaseFactory Java MongoDB ClassNotFoundException:org.springframework.data.convert.CollectionFactory - Java MongoDB ClassNotFoundException: org.springframework.data.convert.CollectionFactory mongodb org.springframework.data.authentication.UserCredentials未找到默认构造函数 - mongodb org.springframework.data.authentication.UserCredentials No default constructor found org.springframework.data.mongodb.core.mapping.Document 无法引用 - org.springframework.data.mongodb.core.mapping.Document cannot reference Spring Data MongoDB Core 1.9.1.RELEASE提供了java.lang.NoClassDefFoundError:org / springframework / data / geo / GeoResults - Spring Data MongoDB Core 1.9.1.RELEASE gives java.lang.NoClassDefFoundError: org/springframework/data/geo/GeoResults 谁知道我可以将org.springframework.core-3.0.5.RELEASE与spring-data-mongodb-1.0.0.M4一起使用吗? - Anyone knows Can I use org.springframework.core-3.0.5.RELEASE with spring-data-mongodb-1.0.0.M4? Spring boot org.springframework.data.repository.config.BootstrapMode - Spring boot org.springframework.data.repository.config.BootstrapMode 使用Embedded MongoDb启动Spring Boot时发生异常 - Exception while starting Spring boot with Embedded MongoDb
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM