Spring Data Rest json-patch+json on collection item with index greater than 9

Spring Data Rest json-patch+json on collection item with index greater than 9

实体 Parent 有一个 Item 对象集合。

每当我尝试 运行 一个 json-patch+json 包含针对索引大于 9 Spring 的集合项的操作的请求时,抛出以下内容异常:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property 10 found for type Item! Traversed path: Parent.collection.

URL 是 "/Parent/1" 请求正文:

[
    {
      "op":"replace",
      "path":"/collection/10/property",
      "value":"100"
    }
]

索引小于 10 的完全相同的请求工作正常:

[
    {
      "op":"replace",
      "path":"/collection/9/property",
      "value":"100"
    }
]

它是 spring 数据休息错误吗?

There was an issue in Spring Data Rest project that has recently been fixed(2018 年 8 月 8 日)在以下版本中:

org.springframework.data:spring-data-rest-webmvc:jar:3.1.0.RC2 org.springframework.data:spring-data-rest-webmvc:jar:2.6.15.RELEASE org.springframework.data:spring-data-rest-webmvc:jar:3.0.10.RELEASE

如果您使用 Spring Boot 2.1.x,您可以更新您的 spring-data-rest-webmvc 工件版本。最简单的方法是在您的 pom 中将 spring-data-releasetrain.version 属性 设置为 Lovelace-RC2:

<spring-data-releasetrain.version>Lovelace-RC2</spring-data-releasetrain.version>

如果你使用Spring启动2.0.x:

<spring-data-releasetrain.version>Kay-SR10</spring-data-releasetrain.version>

如果你使用Spring引导1.5.x:

<spring-data-releasetrain.version>Ingalls-SR15</spring-data-releasetrain.version>

作为替代方案,您可以将 Spring 引导版本本身更新为已经使用相应 Spring Data Rest 版本的版本:

org.springframework.boot:spring-boot-starter-parent:2.1.0.M2 (Lovelace-RC2)

org.springframework.boot:spring-boot-starter-parent:2.0.5.RELEASE (Kay-SR10)

org.springframework.boot:spring-boot-starter-parent:1.5.16.RELEASE (Ingalls-SR15)