考虑Custom implementations for Spring Data repositories我使用存储库中的@RepositoryRestResource
把所有的HATEOAS产生goodnes:春季数据REST/HATEOAS用自定义的方法实现
@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepository extends PagingAndSortingRepository<PersonNode,Long>,
PersonRepositoryCustom {
List<PersonNode> findBySurname(@Param("0") String name);
}
现在下面所提到的文档,我创建了PersonRepositoryCustom
额外的,简单的对于入门的目的方法:
public interface PersonRepositoryCustom {
public String printPerson(PersonNode personNode);
}
实现是:
public class PersonRepositoryImpl implements PersonRepositoryCustom{
@Override
public String printPerson(PersonNode personNode) {
return "It Works!";
}
}
我想让默认的SDR自动生成的端点保持不变,只需添加新的自定义方法/新实现。 我该如何使用spring-data Rest/HATEOAS这个自定义方法? 使用简单的@RepositoryRestResource
控制器端点自动生成。如果我想提供一些自定义方法怎么办?我认为我将不得不手动创建控制器,但在这个示例中应该如何看待?