1. 程式人生 > >spring data jpa 裡 Dao層中Repository和JpaSpecificationExecutor的一個小坑

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屬性。

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