POST的自定义控制器方法隐藏了GET的rest存储库端点

时间:2014-11-11 19:38:46

标签: spring-data-rest

我有一个spring-data-rest存储库,用于公开/学生和/学校的休息端点(/学校repo是只读的,但/学生是读/写)。

我创建了自己的自定义控制器,只使用了@RequestMapping的保存方法(value =“/ schools / {id} / students”,method = RequestMethod.POST)。 save方法基本上允许我将学生添加到学校而无需向学校存储库添加save()。

但是现在当我运行我的应用程序时,我已经丢失了/ schools / {id} / students的GET端点(方法不允许)。

这是否意味着我将不得不在我的控制器中重新实现该GET方法?真是太痛苦了。有什么方法可以解决这个问题吗?

使用spring boot 1.1.8.RELEASE

回购

@RepositoryRestResource(path = StudentLinks.STUDENT, collectionResourceRel = StudentLinks.STUDENT, exported = true)
public interface StudentRestRepository extends ReadOnlyRepository<Student, Long> {

    Student save(Student entity);

}


@RepositoryRestResource(path = SchoolLinks.SCHOOL, collectionResourceRel = SchoolLinks.SCHOOL, exported = true)
public interface SchoolRestRepository extends ReadOnlyRepository<School, Long> {

}

0 个答案:

没有答案
相关问题