SpringJPA spring_data_jpa_No property %s found for type %s!
环境
spring-data-jpa 2.x
异常
我使用单元测试,测试 repository 里面的方法。
// 其他异常堆栈信息已省略,核心问题就是下面这个。
No property %s found for type %s!
-
第一个 %s 代表 repository 里面的定义方法中的某个属性
-
第二个 %s 代表实体类
原因
/**
* @author wangxiao
* @since 2021.6.24
*/
public interface AccountRepository extends PagingAndSortingRepository<AccountEntity, Integer>, JpaSpecificationExecutor<AccountEntity> {
void findByMou();
}
如果`AccountEntity里面没有 mou 这个属性,就会产生
`No property mou found for type AccountEntity!