[英]How does delete operation work with Rest in Spring Data
Currently we have exposed our methods like this 目前,我们已经公开了这样的方法
@RestController
@RequestMapping("/app/person")
public class PersonResource {
@Timed
public void delete(@PathVariable Long id) {
log.debug("REST request to delete Person: {}", id);
personRepository.delete(id);
}
}
The operations of this method, in terms of input and output, are very clear to the user developer. 对于用户开发人员而言,就输入和输出而言,此方法的操作非常清楚。
This article http://spring.io/guides/gs/accessing-data-rest/ shows how to expose JPARepositories directly obviating the need of a service layer. 本文http://spring.io/guides/gs/accessing-data-rest/显示了如何直接公开JPARepositories,而无需使用服务层。
@RepositoryRestResource(collectionResourceRel="people", path="people")
public interface PersonRepository extends JpaRepository<PersonEntity, Long> {
}
It is not obvious to me how I can make a "delete operation" available with PathVariable Long id. 对我来说,如何使用PathVariable Long id使“删除操作”变得不明显。
There is an excellent article on this topic. 关于这个话题有一篇很好的文章。 https://github.com/spring-projects/spring-data-rest/wiki/Configuring-the-REST-URL-path But it actually shows how to supress export of a delete operation. https://github.com/spring-projects/spring-data-rest/wiki/Configuring-the-REST-URL-path但实际上显示了如何禁止删除操作的导出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.