Spring boot Mapstruct StackOverFlow Error

前端 未结 1 1830
忘了有多久
忘了有多久 2021-01-03 05:29

I\'m using mapstruct to map my entity and dto classes... I\'m having problem with a loop on my mapper class...

I have no ideia what to do... This is my mapper classe

相关标签:
1条回答
  • 2021-01-03 06:09

    You have a cyclic dependency between VehicleType and Brand. You have 3 possibilities to resolve the cycles:

    1. One mapper will always ignore the cyclic field. I see that you have @JsonIgnore on the list of Brand in the VehicleType. You could ignore them via Mapping#ignore in your mapper.

    2. You will have explicit mappings that ignore what you don't need and use qualifiers to choose the appropriate methods. More info about qualifiers here in the documentation

    3. Use the latest release of 1.2.0 (at the time of answering 1.2.0.RC1 and use the new @Context parameter. Have a look at the mapping-with-cycles from the mapstruct examples repository. It solves cyclic mapping problems. You don't have to use Object, you can also use your specific types instead.

    NOTE: The 1.2.0 release does not offer "out of the box" solving of cyclic mapping, it needs to be done by the users explicitly.

    0 讨论(0)
提交回复
热议问题