问题描述
我使用带有spring.data.rest.base-path
属性设置为/api
的Spring Data REST。如果为CrudRepository
实体扩展User
,则我的RESTful服务中将有一个/api/users
端点可用。现在假设,我想像这样向/api/users
添加自定义端点:
@RepositoryRestController
public class UserController {
@PatchMapping(path = "/users/{username}/update",produces = "application/hal+json")
@ResponseStatus(HttpStatus.OK)
public EntityModel<User> updateUser(@PathVariable String username,@RequestBody User user) {
// some update logic here ...
return EntityModel.of(user);
}
}
@PatchMapping
批注中的path元素仍包含显式硬编码的/users
部分。是否有任何编程方式将其替换为Spring Data REST管理的User
类型的集合资源的路径变量?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)