Mapping of Enums via @Mapping is removed. Please use @ValueMapping instead!

Problem: In Java when you are using Mapstruct and it returns next error:

Mapping of Enums via @Mapping is removed. Please use @ValueMapping instead!

Solution: The problem is that you are using @Mapping and you have to use @ValueMapping when you are mapping Enums.

Example:

//Correctly mapping between enums

@ValueMapping(source="value1_typeTwo", target="value1_typeOne")
@ValueMapping(source="value2_typeTwo", target="value2_typeOne")
@ValueMapping(source="value3_typeTwo", target="value3_typeOne")
TypeOneEnum typeTwoEnumToTypeOneEnum(TypeTwoEnum typeTwoEnum)

For more interesting tutorials & guides just check them HERE.

5 Comments

  1. Hey! Someone in my Myspace group shared this site with us
    so I came to give it a look. I’m definitely loving the
    information. I’m book-marking and will be tweeting this to my followers!
    Great blog and fantastic design.

Leave a Reply

Your email address will not be published. Required fields are marked *