嗨我在使用mapstruct从Child Source类设置它时,在DTO中为List操作获取null.有人可以帮我解决这个问题.请在这里找到我的代码
实体类:
public class Source {
int id;
String name;
List<ChildSource> childSource;
//getters and setters
}
public class ChildSource {
String code;
String action;
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
DestinationDTO:
public class TargetDTO{
int sNo;
String mName;
List<String> actions;
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
MApper类:
@Mapper(componentModel = "spring")
public abstract class SampleMapper {
@Mappings({
@Mapping(target = "id", source = "sno"),
@Mapping(target = "name", source = "mNAme")
})
public abstract TargetDTO toDto(Source source);
@IterableMapping(elementTargetType = String.class)
protected abstract List<String> mapStringtoList(List<ChildSource> childSource);
protected …Run Code Online (Sandbox Code Playgroud)