2019独角兽企业重金招聘Python工程师标准>>>

解决方法

解决方法详见:spring data jpa @Entity property not found exception

上面大致意思

你为User实体类定义了一个UserRepository,这个UserRepository中的findByName(String name);方法是通过`name` (方法的参数位置)去查询数据。但是这个`name` 并不是User实体类的属性(XXX is not a property of your Domain class)。(不知道小弟有没有表达清楚,没有明白的请点击这里查看原文>_<)

解决办法有两种

1、把参数名称改成实体中的属性。比如本例中User实体类中有firstname 和lastname 这两属性,就可以把public User findByName(String name);方法的参数`name` 改成firstname 或lastname 。

2、也有可能是一不小心,把实体类中的属性名称写错了哦(见下图)

3、如果是使用主键进行查询的,可以这样式儿的:

这个解决方法有没有用?

为啥会出现这个错误?

好了,下面开始记录解决这个问题的经历:

事情的起因

朋友发给我一段异常信息是这样式儿的:

Error creating bean with name 'customerPackageServiceImpl':Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException:Could not autowire field:private com.fuze.erp.service.customer.ICustomerService com.fuze.erp.service.customer.impl.CustomerPackageServiceImpl.iCustomerService;
nested exception is org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'customerServiceImp':Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException:Could not autowire field:private com.fuze.erp.repository.customer.CustomerRepository com.fuze.erp.service.customer.impl.CustomerServiceImp.customerRepository;
nested exception is org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'customerRepository':Invocation of init method failed;
nested exception is org.springframework.data.mapping.PropertyReferenceException:No property customerId found for type Customer!

然后我就定位到了最后一句话: No property customerId found for type Customer!然后:

按下按钮后,百度上竟然没有相关文章。去谷歌搜了一下,我去。。竟然也没有!!几近疯狂,最后还是在谷歌中找到了线索:(最后折腾那么就的原因 是我错误的理解了报错信息)

参考

org.springframework.data.mapping.PropertyReferenceException: No property detachItem found for type Fruit

Working with Spring Data Repositories

Spring Data JPA - “No Property Found for Type” Exception

Spring Data for Mongo 方法名规范介绍

转载于:https://my.oschina.net/anxiaole/blog/873695

org.springframework.data.mapping.PropertyReferenceException: No property xxxx found for type Xxxx相关推荐

  1. org.springframework.data.mapping.PropertyReferenceException: No property item found for type BItem!

    Caused by: org.springframework.data.mapping.PropertyReferenceException: No property item found for t ...

  2. org.springframework.data.mapping.PropertyReferenceException: No property * found for *

    报错信息: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with n ...

  3. No property creategoryType found for type xxx! Did you mean ‘xxx‘?

    使用jpa进行查询的时候报了这个错误 java.lang.IllegalStateException: Failed to load ApplicationContextat org.springfr ...

  4. 用springboot jpa 报:No property yer found for type OrderMaster错

    报错代码 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with na ...

  5. Java接收solr动态域_Spring Data Solr创建动态域报错:org.springframework.data.solr.UncategorizedSolrException...

    今天在项目中使用Spring Data Solr导入动态域数据报错, 控制台打印错误信息如下 Exception in thread "main" org.springframew ...

  6. org.springframework.data.redis.serializer.SerializationException: Cannot serialize;

    错误: . ____ _ __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\ ...

  7. data mapping

     数据映射(Data Mapping):给定两个数据模型,在模型之间建立起数据元素的对应关系,将这一过程称为数据映射.  ETL包括三个阶段:数据抽取(extract),数据转换(transform) ...

  8. MongoDB填坑Can't find a codec for class org.springframework.data.mongodb.core.query.GeoCommand

    之前我写过一篇文章:MongoDB LBS经纬度查询操作,我再后续的实战中发现了一些坑,再次帮大家填一下! Geo字段顺序问题 注意一下location中lng(经度),lat(纬度),按照这个顺序查 ...

  9. org.springframework.data.mongodb.UncategorizedMongoDbException

    在使用mongodb数据库执行带条件查询操作时遇到以下问题: org.springframework.data.mongodb.UncategorizedMongoDbException: Query ...

最新文章

  1. 发测试邮件或垃圾邮件node脚本
  2. 阿里青橙奖名单公布,23位院士、2位图灵奖得主推荐
  3. ES6新特性:Javascript中的Reflect对象
  4. 程序员的数学全三册密码_阿波罗50年前成功登月,少不了这位硬核女程序员
  5. python极简教程_Python 极简教程(六)运算符
  6. 在电脑上显示未知发布者怎么办_笔记本电脑显示器花屏怎么办?电脑屏幕花屏的解决方法...
  7. NPOI 操作EXCEL 小计
  8. 第一个冲刺周期(第四天)
  9. 促销海报灵感素材,不卖出去都难
  10. c语言学习之结构篇代码演示样例-输入n个同学的姓名,数学英语成绩,依照平均分从低到高排序并输出...
  11. python类中包含一个特殊的变量、它表示当前对象自身_知到APP教师职场礼仪第七单元章节测试网课答案大学课后答案...
  12. 用python实现一个socket echo程序 tcp socket的几个关闭状态
  13. 【月径流预测】基于matlab未来搜索算法算法优化BP神经网络月径流预测【含Matlab源码 2001期】
  14. [2018.10.18 T3] 小 G 的线段树
  15. 怎么查看电脑连接的wifi密码?2种方法分享给大家!
  16. vue+element实现一个excel表格下载的功能
  17. keycloak 添加 注册邮箱后缀验证
  18. 关于 退步编程 和 退步看书的思考
  19. 设计模式(四)责任链模式——责任链模式结构
  20. 多重循环打印图形(3)——打印平行四边形

热门文章

  1. 如何开启匿名访问SharePoint 2010里的Client Object Model
  2. python列表解析的新方法
  3. 14.4 exportfs命令 14.5 NFS客户端问题 15.1 FTP介绍 15.2/15.3
  4. Struts2学习笔记-part1: 快速起步
  5. 一网打尽当下NoSQL类型、适用场景及使用公司
  6. 2016年十大存储预测
  7. mybatis 1 - 获取自增ID
  8. java线程学习-Thread.currentTread().getName()和this.getName()的区别
  9. 《花田半亩》有感——午夜静静地震撼着我的生命(不是技术,发在首页,只是因为感动)...
  10. 构建一个业务连续的网络