Solution for “Failed to create query for method” f

2019-08-23 03:20发布

So, I was getting this exception when starting up my app that uses spring-data-jpa 2.0.3

java.lang.IllegalArgumentException: Failed to create query for method public abstract package.Entity package.repositories.EntityRepository.findOne(java.lang.Integer)! No property findOne found for type Entity!

So, the issue was that my EntityRepository extends CrudRepository. CrudRepository already provides the findOne() method. A previous developer had duplicated the method in our EntityRepository interface. By removing the duplicate method, everything worked.

I also had to remove the findAll() : List methods. In this case, it wasn't a straight removal, because the CrudRepository returns Iterable instead. Still an easy fix.

0条回答
登录 后发表回答