所以我玩了一下 Mapstruct,阅读了版本 1.1.0.Final 的参考文档,并得出了这一点:隐式类型转换 http://mapstruct.org/documentation/stable/reference/html/#implicit-type-conversions
其中定义了以下语句:
JAXBElement 和 T 之间
我尝试过,但收到的错误是:
Can't map property "java.lang.String xmlElement" "javax.xml.bind.JAXBElement<java.lang.String> xmlElement".
Consider to declare/implement a mapping method:
javax.xml.bind.JAXBElement<java.lang.String> map(java.lang.String value)".
我知道这是同一个线程使用 MapStruct 时无法映射属性 https://stackoverflow.com/questions/34672216/cant-map-property-when-using-mapstruct但此后 Mapstruct 发布了新版本。
是我做错了什么还是这个功能真的缺失了?
谢谢。
映射自JAXBElement<T>
to T
开箱即用。相反,您需要确保ObjectFactory
(ies) 位于Mapper#uses
、MapStruct 使用这些方法来创建类型。
您还可以看看this https://github.com/mapstruct/mapstruct/tree/master/integrationtest/src/test/resources/jaxbTest集成测试。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)