如何将具有动态字段的实体转换为 Spring Roo 实体
我有一个日志记录实体,需要映射一个动态属性集的实体,其中 JSON 数据如下所示:
{
"timestamp" : ISODate("2012-01-17T22:30:19.839Z"),
"level" : "INFO",
"thread" : "main",
"properties" : {
"cookieId" : "EDE44DC03EB65D91657885A34C80595E"
"field-1" : "foo"
"field-n" : "bar"
},
"applicationName" : "D2",
"eventType" : "Development"
}
如何创建一个用于拉取字段的动态属性对象?
任何帮助将不胜感激。
I have a Logging Entity that needs to map an Entity that is a dynamic set of Properties where the JSON data looks like this:
{
"timestamp" : ISODate("2012-01-17T22:30:19.839Z"),
"level" : "INFO",
"thread" : "main",
"properties" : {
"cookieId" : "EDE44DC03EB65D91657885A34C80595E"
"field-1" : "foo"
"field-n" : "bar"
},
"applicationName" : "D2",
"eventType" : "Development"
}
How can I create a Properties object that is dynamic for pulling fields?
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该创建像 java.util.Map 这样的字段。
示例:
field other --fieldName properties --type java.util.Map
我尝试使用
web mvc
,但它不是工作属性,因为这种类型不存在自定义编辑器......因此,如果你想与 spring mvc 一起使用,你必须为此编写自定义编辑器。
PS:创建此字段后,建议将该通用类型更改为
...U should create field like java.util.Map .
example:
field other --fieldName properties --type java.util.Map
I try that with
web mvc
, but it's not working property, because a custom editor not exist for this type.....So if U wanna use with spring mvc U have to write your custom editor for that.
PS: after you created this field recommended change that generic type to
...<String,Object>