代码之家  ›  专栏  ›  技术社区  ›  riccardo.cardin

Spring Data Mongo:处理字段名中的“$”字符

  •  1
  • riccardo.cardin  · 技术社区  · 4 年前

    我正在使用Spring Data Mongo 2.1.5.RELEASE将我的Spring Boot 1.5.15服务连接到MongoDB 3.2。此版本的Mongo的问题是字段属性名不能包含以下字符 $ : Restrictions on Field Names .

    尝试使用具有此类字符的属性时,我得到以下错误:

    com.mongodb.MongoCommandException: Command failed with error 52 (DollarPrefixedFieldName): 'The dollar ($) prefixed field '$NAME' in 'fields.$NAME' is not valid for storage.'
    

    有没有办法指导 MappingMongoConverter 更改字符 $ 在数据库的I/O过程中?

    谢谢。

    0 回复  |  直到 4 年前