首页 > 解决方案 > ModelMapper 无法将 java.util.List 转换为 java.util.List

问题描述

我尝试使用 ModelMapper 将 @Entity 转换为 DTO,因此出现此错误:

org.modelmapper.MappingException: ModelMapper mapping errors:

1) Converter org.modelmapper.internal.converter.CollectionConverter@f3e6876 failed to convert java.util.List to java.util.List.

1 error

有人可以帮助我吗?

标签: javaspring-bootmodelmapper

解决方案


真正的问题是:

Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.backapi.aviso.domain.Aviso.links, could not initialize proxy - no Session

解决方法: @ElementCollection(fetch = FetchType.LAZY)


推荐阅读