在我们的 Spring-boot 应用程序中,我们有以下简单的
SseStatusDto
DTO:
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SseStatusDto {
private String currentPhase;
private int percentage;
private String result;
}
出于某种我无法理解的原因,Spring 在尝试将信息发送回客户端时无法将此 DTO 转换为 JSON:
emitter.send(SseEmitter.event()
.data(SseStatusDto.builder()
.currentPhase("DONE")
.percentage(100)
.result("temp-result")
.build()), MediaType.APPLICATION_JSON);
我得到了
java.lang.IllegalArgumentException: No suitable converter for class <class>
我错过了什么?
尝试为 SseStatusDto 模型添加 getter 和 setter:
@Builder
@AllArgsConstructor
@NoArgsConstructo
@Getter
@Setter
public class SseStatusDto {
private String currentPhase;
private int percentage;
private String result;
}