我在RevisionRepository
为我的存储库公开(Spring Data Envers)端点时遇到问题,扩展RevisionRepository
如下:
@RepositoryRestResource(path = "disciplines", itemResourceRel = "disciplines") public interface DisciplineRepository extends RevisionRepository, CrudRepository { @RestResource(path = "findByName", rel = "findByName") List findByName(String name); }
只findByName
暴露方法,有没有其他方法来公开方法RevisionRepository
?我也尝试覆盖这些方法,DisciplineRepository
但它不起作用.
谢谢...
您必须编写一个自定义控制器方法来实现它,如下所示:
@Autowired private DisciplineRepository disciplineRepository; @RequestMapping(value = "/disciplines/{id}/changes", method = RequestMethod.GET) public ResponseEntity> getDisciplineRevisions(@PathVariable(value = "id")Discipline discipline) { if (discipline != null) { Revisions disciplineRevisions = disciplineRepository.findRevisions(discipline.getId()); return new ResponseEntity<>(new Resource<>(disciplineRevisions), HttpStatus.OK); } else { throw new ResourceNotFoundException(); } }