gpt4 book ai didi

java - Spring data rest - 是否有一个全局开关来阻止所有删除操作?

转载 作者:搜寻专家 更新时间:2023-11-01 03:47:55 26 4
gpt4 key购买 nike

我目前正在对存储库中的所有删除操作使用 @RestResource(exported = false) 来隐藏删除请求。这是在扩展 JPA 存储库的存储库中显式完成的。

是否有一个全局开关来阻止所有删除操作?

最佳答案

没有。您需要使用 @RestResource(exported = false) 注释所有删除操作。

来自 Spring 数据文档的示例:

@RepositoryRestResource(path = "people", rel = "people")
interface PersonRepository extends CrudRepository<Person, Long> {

@Override
@RestResource(exported = false)
void delete(Long id);

@Override
@RestResource(exported = false)
void delete(Person entity);
}

解释如下:

If you want turn them off, then just keep in mind you have to annotate both versions with exported = false.

所以默认情况下,如果没有新的你需要注释你所有的操作。但是,如果您目前非常感兴趣,您可以使用执行此操作的实现来执行您自己的注释。

关于java - Spring data rest - 是否有一个全局开关来阻止所有删除操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38929982/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com