我正在使用 spring boot 和 jackson 来创建休息 api。我知道 @JsonProperty
注释有 defaultValue
字段。
在
这是javadoc,它说:
textual default value defined as metadata. NOTE: core databind does NOT make any use of this value; it is currently only exposed to extension modules.
所以我在 maven 中央存储库上找到了 jackson 的一些模块,但是我找不到关于应该使用哪个扩展来启用 defaultValue 处理的任何软件信息。
有这样的模块吗?
最佳答案
根据 JsonProperty 的文档,defaultValue 属性可用于记录预期的默认值。他们在 2.5 版本中添加了此属性。根据他们的观点
It is possible that in future this annotation could be used for value defaulting, and especially for default values of Creator properties,since they support {@link #required()} in 2.6 and above.
截至 2.8 版本,我们无法使用此注释来设置默认值。这里我们可以依赖Java来为成员变量提供默认值。
关于java - 带有 @JsonProperty defaultValue 处理的 Jackson 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43238548/