我在Spring Boot应用程序中使用mapstruct将Dto映射到Entity,反之亦然。
我想知道,如果使用Mapstruct @Mapping()将任何String值作为空映射到null值,我是否可以映射?
可能吗?
提前致谢
您可以简单地expression
在@Mapping
@Mapping(target = "name", expression = "java(source.name.isEmpty() ? null : source.name)")
Dog convert(Cat source);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句