【问题标题】:Version property missing when converting Domain to JSON将域转换为 JSON 时缺少版本属性
【发布时间】:2021-03-10 15:51:00
【问题描述】:

在 GORM-standalone 中,我有一个简单的域类,例如:

@JsonIgnore( [ 'owner' ] )
class Person implements MongoEntity<Person>{
  String id
  String name
  String owner

  Long version // attempt to hack
}

当 Person 实例转换为 JSON 时,version 不会输出到结果 JSON 字符串。

有什么方法可以自动完成?

附: 即使明确添加 version 属性也不会将其添加到生成的 JSON...

【问题讨论】:

    标签: json groovy jackson grails-orm gorm-mongodb


    【解决方案1】:

    您可以在grails-app/conf/Config.groovy中设置配置属性

    grails.converters.domain.include.version = true
    

    grails-app/conf/application.yml

    grails:
      converters:
        domain:
          include:
            version: true
    

    【讨论】:

    • 我没有使用 Grails,只有 GORM-SA
    猜你喜欢
    • 2022-09-23
    • 1970-01-01
    • 2023-03-06
    • 2017-03-19
    • 1970-01-01
    • 1970-01-01
    • 2018-06-24
    • 2018-11-16
    • 2016-06-01
    相关资源
    最近更新 更多