Spring Data Couchbase:方法findBy对象抛出java.lang.IllegalArgumentException“ JsonArray不支持的类型”

时间:2019-12-17 19:12:10

标签: spring spring-data couchbase illegalargumentexception spring-data-couchbase

我创建了一个Spring Boot项目。指定的数据模型:

 import { Component, OnInit } from '@angular/core';

 @Component({
  selector: 'app-dado',
  templateUrl: './dado.component.html',
  styleUrls: ['./dado.component.css']
 })

 export class DadoComponent implements OnInit {
  valor: number;
  constructor() { }

  ngOnInit() {
   this.valor = Math.trunc(Math.random() * 6) + 1;
  }

 }

还创建了反应性存储库:

  <div class="forma">
   {{valor}}
  </div>

调用方法 findByChild 产生了一个异常:


@Document
public class User {

    @Id
    private String id;

    @Field
    private String firstname;

    @Field
    private List<Child> children;

    public User(String id, String firstname, List<Child> children) {
        this.id = id;
        this.firstname = firstname;
        this.children = children;
    }

    static class Child {
        private String name;
        private int age;

        Child(String name, int age) {
            this.name = name;
            this.age = age;
        }

    }

}

版本:Spring boot 2.2.2.RELEASE spring-data-couchbase-3.2.3。发布

为什么Spring-Data扩展不能将 User 对象转换为 JsonObject ? 但是,方法 getByFirstname 可以正常工作。

谢谢!

1 个答案:

答案 0 :(得分:1)

有多个JsonArray类,请查看您要导入的类,以确保它是沙发床jsonarray