结论先行:
在继承JpaRepository的接口中,其方法名不能与实现类有所差异,即使是包装类型的也不行。
重现过程:
1、定义接口
public interface LatentUserRepository extends JpaRepository<LatentUser, Integer> {
List<LatentStatusStat> statSpecialByStatus(Integer specialId);
}
2、定义实现接口
public List<LatentStatusStat> statSpecialByStatus(int specialId) {
//...
return null;
}
3、启动Tomcat报错,
PropertyReferenceException: No property statSpecialByStatus found for type LatentUser!
分析原因:
参数有不同,一个是Integer类型,一个是int,所以Spring在反射的时候,当成了2个不同的方法。
解决方法:
都改成int,或者都改成Integer。