繁体   English   中英

“使用名称创建 bean 时出错……”它发生在 MongoRepository 的一个实例中,我使用的是 Java11 和 springboot

[英]“Error creating bean with name …” it happens in an instance of MongoRepository, I'm using Java11 and springboot

我无法通过我的生活找到解决这个问题的方法xD

错误如下:


org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'itemHandler': Unsatisfied dependency expressed through field 'repo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemRepository' defined in com.example.demo.service.itemRepository defined in @EnableMongoRepositories declared on MongoRepositoriesRegistrar.EnableMongoRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property findbyidItem found for type ItemObject!

如果您想查看代码,该应用程序非常小: https://bitbucket.org/ZeroD0Z/zerod0z-api/src/master/demo/src/main/java/com/example/demo/

您应该重命名您的存储库方法,正确的名称应该是大写的属性名称,(以及关键字 By 也)。 所以正确的名称是(注意 IdItem):

ItemObject findByIdItem (String idItem);

否则,JPA 无法解析属性名称。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM