@EnableElasticsearchRepositories SpringbootRedisMqEsStudentsystemApplication: Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property name found for type Student! Did you mean 'sname'?
说是我Student类里没有sname
错误代码为:
@Repository
public interface StudentEsDao extends ElasticsearchRepository<Student,String> {
List<Student> findByname(String sname);
}
Student实体类代码:
@Document(indexName = "studentsystem")
public class Student implements Serializable {
@Id
private String sid;
private String sname;
......
}
出错的原因是:我的方法名findByname,而By后面的name与Student 的sname不一致而报的错,把方法名改为findBysname 或者findBySname就可以了