You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error: Qualifier error. No method found annotated with @Named#value: [ stringToEnum ]. See https://mapstruct.org/faq/#qualifier for more info.
@Mapping(source = "message", target = "messageA", qualifiedByName = "stringToEnum")
error: Can't map property "String message" to "EnumMessageA messageA". Consider to declare/implement a mapping method: "EnumMessageA map(String value)".
@Mapping(source = "message", target = "messageA", qualifiedByName = "stringToEnum")
I only way to get this working for MapStruct to use the customer mapper method for string to enum, is move the mapStringToEnum inside a helper class make it static, and pass the helper class in @Mapper uses attribute.
So my modified code should look like this to work:
I've seen that the Named annotation exists in multiple packages so it might be that you had the wrong import for the annotation.
Not org.mapstruct.Named but for example javax.inject.Named.
MapStruct version: 1.4.2.Final
Here is my sample code setup:
Here is the test class:
I get this compilation error:
I only way to get this working for MapStruct to use the customer mapper method for string to enum, is move the
mapStringToEnum
inside a helper class make it static, and pass the helper class in@Mapper uses
attribute.So my modified code should look like this to work:
The text was updated successfully, but these errors were encountered: