mapstruct-idea icon indicating copy to clipboard operation
mapstruct-idea copied to clipboard

Plugin won't recognize @Named class

Open BartekGierej opened this issue 2 months ago • 0 comments

I was trying to implement this pattern from documentation:

Image

As for mapper itself, it is working fine and dandy. The plugin, however, seems to have problem with finding the annotated class which contains annotated mapping method. Error description is provided:

"Unknown @ Named reference 'TranslationMapper' ".

Reference for "TranslationsToString" is found properly.

@Mapper(uses = TranslationMapper.class)
public interface PrimaryClassMapper {
    @Mapping(source = "primary.id", target = "id")
    @Mapping(
            source = "primary.translatedNames",
            target = "name",
            qualifiedByName = {"TranslationMapper", "TranslationsToString"})
    SecondaryClass toSecondaryClass(PrimaryClass primary, @Context Language targetLanguage);
}
@Named("TranslationMapper")
public class TranslationMapper {
    @Named("TranslationsToString")
    public String resolveTranslatedText(
            List<TranslationDto> translations, @Context Language targetLanguage) {
        //some fancy logic
    }
}

BartekGierej avatar Dec 08 '25 11:12 BartekGierej