Home Trouble Shooting(Spring)
Post
Cancel

Trouble Shooting(Spring)

Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.

Main Application 파일을 java 폴더 바로 밑에 두어서 생기는 문제이다.

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance

1
2
3
4
5
6
7
8
9
10
@Getter
@Setter
@Builder
@AllArgsConstructor
public class PeopleInfo {
    private int id;
    private int numberOfCurrentPeople;
    private int numberOfNewPeople;
    private String time;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
public class PeopleInfoDeserializer implements Deserializer<PeopleInfo> {
    @Override
    public PeopleInfo deserialize(String topic, byte[] data) {
        ObjectMapper mapper = new ObjectMapper();
        PeopleInfo peopleInfo = null;
        try {
            peopleInfo = mapper.readValue(data,PeopleInfo.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return peopleInfo;
    }
}

위와 같이 정의해 두었을때, byte 배열을 PeopleInfo로 deserialize할때 발생한 에러이다. 해결책은 PeopleInfo에 아래와 같이 Default 생성자를 선언해놓으면 된다.

1
2
3
4
5
6
7
8
9
10
11
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor // 추가!
public class PeopleInfo {
    private int id;
    private int numberOfCurrentPeople;
    private int numberOfNewPeople;
    private String time;
}
This post is licensed under CC BY 4.0 by the author.

Kafka Command

command(Redis)

Comments powered by Disqus.

Trending Tags