我試圖覆蓋mongo倉庫的findAll(Pageable pageable)
方法,但不能完全做到這一點。如何覆蓋Mongo Repository的findAll方法
我創建了一個名爲MyRestRepository
庫,看起來像這樣:
public interface MyRestRepository extends MongoRepository<Notify, String>, MyRestRepositoryCustom {
...
}
裏面的MyRestRepositoryCustom
界面我加入這個代碼:
@Modifying
Page<Notify> findAll(Pageable pageable);
最後我有MyRestRepositoryCustom
實現:
public class MyRestRepositoryImpl implements MyRestRepositoryCustom {
@Override
public Page<Notify> findAll(Pageable pageable) {
// This doesn't work
Page<Notify> results = super.findAll(pageable);
// Do other stuff here to results...
return results;
}
我想打電話給t他在原始存儲庫中找到所有方法,以便我可以獲取頁面的內容,然後對其進行修改。但是,這不起作用。我怎樣才能做到這一點??
是否要覆蓋它爲一個存儲庫或應用程序中的所有存儲庫? – jny
對於一個特定的存儲庫。你能提供一些代碼和你的答案嗎? – Tometoyou
我更新了答案 – jny