spring data jpa 裏 Dao層中Repository和JpaSpecificationExecutor的一個小坑

public interface LabelRepository extends Repository<Label, Long>,JpaSpecificationExecutor<Label> {
	
	List<Label> findAll();
	
	Label save(Label label);

    Label update(Label label);
}

項目啓動就會報錯,由於Repository和JpaSpecificationExecutor中是沒有update方法的,項目掃包的時候,發如今Repository和JpaSpecificationExecutor中沒有update方法,就認爲LabelRepository中的update方法是實體類Label中的一個屬性,而後再實體類中又沒有找到update屬性,就會報錯說實體類缺乏update屬性。java

解決方法就是把update給刪除掉,更新功能使用save方法就能夠實現。code

相關文章
相關標籤/搜索