Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json @RestResource(exported=false)被忽略_Json_Spring_Spring Data Rest - Fatal编程技术网

Json @RestResource(exported=false)被忽略

Json @RestResource(exported=false)被忽略,json,spring,spring-data-rest,Json,Spring,Spring Data Rest,如标题所示,字段上的my@RestResource(exported=false)被忽略。SpringDataREST仍然希望从中生成json,我现在只想跳过它,因为在WorkflowEvent中更改rel没有给我任何帮助 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "submission") @OrderBy("date desc") @RestResource(exported = fal

如标题所示,字段上的my@RestResource(exported=false)被忽略。SpringDataREST仍然希望从中生成json,我现在只想跳过它,因为在WorkflowEvent中更改rel没有给我任何帮助

 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "submission")
@OrderBy("date desc")
@RestResource(exported = false)
private List<WorkflowEvent> events = new ArrayList<WorkflowEvent>();
当然,当我对这个字段进行注释时,它会起作用

我的版本:

\- org.springframework.data:spring-data-rest-webmvc:jar:2.1.4.RELEASE:compile
[INFO] |     \- org.springframework.data:spring-data-rest-core:jar:2.1.4.RELEASE:compile
[INFO] |        +- org.springframework.hateoas:spring-hateoas:jar:0.16.0.RELEASE:compile

@RestResources
仅在指向托管资源的域属性上受支持。因此,如果您没有通过SpringDataREST管理的存储库公开
WorkflowEvent
,那么注释就没有任何效果。在这种情况下,只需使用
@JsonIgnore
就可以让Jackson不呈现属性。

即使它具有repository,那么其他实体中WorkflowEvent属性上的@RestResource(exported=false)也没有效果。如果我删除存储库,它仍会尝试创建指向WorkflowEvent实体的链接。。它在mypackage.WorkflowEvent.Submission上“检测到多个关联链接”时崩溃。这似乎涉及到很多问题。有没有可能提供一个示例项目来查看?虽然
@JsonIgnore
可以工作,但我觉得SpringDataREST应该有一种方法来支持不只是在前端REST端呈现属性。它不应依赖Jackson注释,如果后端也使用Jackson进行json序列化(例如,拍摄实体快照),则可能会与其他后端逻辑冲突@JWLim-这就是它的用途。如果尚未使用,则应将其记录在SD Rest文档中。只是遇到了这个问题,查看了几次文档,却没有发现任何关于这个问题的内容。
\- org.springframework.data:spring-data-rest-webmvc:jar:2.1.4.RELEASE:compile
[INFO] |     \- org.springframework.data:spring-data-rest-core:jar:2.1.4.RELEASE:compile
[INFO] |        +- org.springframework.hateoas:spring-hateoas:jar:0.16.0.RELEASE:compile