Set null to target using mastruct

痴心易碎 提交于 2019-12-06 03:45:29

You can use @Mapping(target = "prop1", expression = "java(null)") to achieve that.

You can find more information about expression in the reference guide here.

Currently only java is supported as an expression language, MapStruct will just take what you have written within the brackets and directly apply it to the setter, the implementation will look exactly like in your example.

Also you can ignore mapping of this property:

@Mapping(target = "prop1", ignore = true)

this will set this value to default which is null in your case

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!