我想将页面转换为页面
所以我这样实现了
@GetMapping("/history")
public Page<ResponseAllHistoryDto> getAllHistory() {
Pageable pageable = PageRequest.of(0, 20, Sort.by("createdAt"));
Page<History> histories = historyRepository.findAll(pageable);
return histories.map(history -> {
return ResponseAllHistoryDto.builder()
.history(history)
.tags(tagRepository.findByHistoryHistoryId(history.getHistoryId()))
.auths(authRepository.findByHistoryHistoryId(history.getHistoryId()))
.build();
});
}
可悲。它给了我
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.wrapsody.demo.ResponseAllHistoryDto and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.data.domain.PageImpl["content"]->java.util.Collections$UnmodifiableRandomAccessList[0])
出什么问题了......:(
答案 0 :(得分:1)
您的DTO
类需要具有默认的构造函数,getter和setter。尝试使用龙目岛的@Data
对其进行注释。