org.springframework.data.mapping.PropertyReferenceException: No property name found for type User

时间:2024-03-16 16:07:42

                                                                 =========解决办法============

原因是在UserDao中用的方法是:List<User> findByUserId(String phone);

org.springframework.data.mapping.PropertyReferenceException: No property name found for type User

org.springframework.data.mapping.PropertyReferenceException: No property name found for type User

按照jpa的规范这个就是去找User类的userId属性去查询,而我的User的类实体是

org.springframework.data.mapping.PropertyReferenceException: No property name found for type User

org.springframework.data.mapping.PropertyReferenceException: No property name found for type User

所以就找不到了;报错了。

现在就是改成:List<User> findById(String phone);

这样就可以了!


===========SpringData方法命名规则===========

org.springframework.data.mapping.PropertyReferenceException: No property name found for type User
org.springframework.data.mapping.PropertyReferenceException: No property name found for type User