web-dev-qa-db-ja.com

リストを返すときに「t」エラーではなく「:」エラーが予期されていましたか?

RequestMappingのリストを返す簡単なUsersメソッドがあります。UsersモデルにはONE TO MANYHolidayDatesとの関係...ただ遊んでいるので、関係(休日に行った日付のリスト)として休日の日付を選択しました。

したがって、ONEユーザーはMANY関連Datesを持つことができます。

ユーザーモデル:

@Entity
@Table(name="user")
public class User {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="userId")
    private int userId;

    @Column(name="about")
    private String about;

    // Maybe change to fetchtype eager
    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "holidayDates")
    private Set<HolidayDates> holidayDates;
    public void setHolidayDates(Set<HolidayDates> holidayDates) {
        this.holidayDates = holidayDates;
    }
    public Set<HolidayDates> getHolidayDates() {
        return holidayDates;
    }
    ...Other setters and getters 

HolidayDateモデル:

@Entity
@Table(name="holiday_dates")
public class HolidayDates {
//
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="holidayId")
    private int holidayId;

    @Column(name="start_date")
    private String startDate;

    @Column(name="end_date" )
    private String endDate;

    @ManyToOne
    @JoinColumn(name = "userId")
    private User user;

以下のコードを使用して、すべてのユーザーと関連する休日の日付を検索します:

@RequestMapping(value="{name}", method=RequestMethod.GET)
public @ResponseBody List<User> user(@PathVariable String name) {
    List<User> user = userService.findAll();
    // Simply implementing List<User> findAll(); from userService auto wired field

    return user;
}

UserServiceには@autowiredフィールドをuserDaoに追加します。これは、JPAリポジトリを単純に拡張します。

public interface UserDao extends JpaRepository <User, Integer> {

コントローラーでGETリクエストを実行すると、次のレスポンスが返されます。

Expected ':' instead of 't'

Fasterxml.jacksonエラーの大きな長いスタックトレースと同様に:

[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:675) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.Java:157) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.Java:149) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:111) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Java:24) ~[jackson-databind-2.6.6.jar:2.6.6]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:693) ~[jackson-databind-2.6.6.jar:2.6.6]

このjpa/modelからjsonへの変換?

12
James111

UserHolidayDatesを参照し、HolidayDatesUserを参照するため、シリアル化中に無限再帰が行われます。 @JsonIgnoregetUserHolidayDatesに追加することで停止できます。

37
jny
@JsonManagedReference
private Set<HolidayDates> holidayDates;

そして

@JsonBackReference
private User user;
2
Manu

私は質問に対する正しい答えがjnyによって受け入れられた答えであることには同意しますが、Spring Bootに悪いJackson objectMapper configをインストールすることでまったく同じ問題を取得しました。何らかの理由で、日付のシリアル化を修正する代わりに、完全に異なるクラス。次のコードを削除すると、再び機能し始めました。誰かが同じ問題を抱えている場合に備えて、これをここに置いてください

@Bean
@Primary
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
    ObjectMapper objectMapper = builder.createXmlMapper(false).build();
    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
//  objectMapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
    return objectMapper;
}
1
triadiktyo

あなたのエラーと同じですが、私の場合、デフォルトのコンストラクタを実装していません。

public User() {}
1
Long Nguyen

この問題は、エンティティクラス間の無限再帰が古いバージョンでは@JsonIgnoreを使用し、新しいバージョンではこのコードを使用するためです。

 @OneToMany(
            mappedBy = "queue_group",fetch = FetchType.LAZY,
            cascade = CascadeType.ALL
        )
    @JsonManagedReference
    private Set<Queue> queues;

@ManyToOne(cascade=CascadeType.ALL)
        @JoinColumn(name = "qid")
       // @JsonIgnore
        @JsonBackReference
        private Queue_group queue_group;
1
Shubham

ユーザーモデルに@ JsonManagedReferenceを追加し、HolidayDatesモデルに@ JsonBackReferenceを追加します

ユーザーモデル:

@OneToMany
 @JsonManagedReference
 private Set<HolidayDates> holidayDates;

HolidayDateモデル:

 @ManyToOne
    @JsonBackReference
    private User user;