自定义查询报错
其他一切正常,但在findByAge();这里报错了。
public interface TestRepository extends JpaRepository<Test,Integer> { //通过年龄查找 public List<Test> FindByAge(Integer age); }
------------------------------------------------------------------
@GetMapping(value = "/ByAge") public List<Test> findByAge(@RequestParam("age") Integer age){ return testRepository.FindByAge(age); }
报错:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testController': Unsatisfied dependency expressed through field 'testRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.example.demo.Repository.TestRepository.FindByName(java.lang.String)! No property findByName found for type Test!
求老师解答。。。百度两小时没找到答案