如何将具有动态字段的实体转换为 Spring Roo 实体

发布于 2024-12-27 16:56:25 字数 397 浏览 3 评论 0原文

我有一个日志记录实体,需要映射一个动态属性集的实体,其中 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘然心甜 2025-01-03 16:56:25

你应该创建像 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>...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文