[SOLVED] Mapstruct: Ambiguous mapping methods found for mapping property


This Content is from Stack Overflow. Question asked by mster3313

I am getting this strange error (Using IntelliJ IDEA 2022.2.2 Ultimate):

Ambiguous mapping methods found for mapping property "java.lang.Short TypeA" to TypeB: TypeB TypeBRepo.getOne(java.lang.Short id), TypeB TypeBRepo.getById(java.lang.Short id), TypeB TypeBRepogetReferenceById(java.lang.Short id)

This happened after I upgraded the spring boot version from 2.1.0.RELEASE to 2.7.2 and maven version from 3.0.0 to 3.8.6.

TypeB Repository extends JPARepository

public interface TypeBRepo extends JpaRepository<TypeB, Short> {

Mapping is done using mapstruct version 1.3.1.Final (Tried with latest mapstruct version also no change)

Following is the mapping

    @Mapping(target = "TypeB", source = "request.TypeA"),
    @Mapping(target = "securityValue", source = "request.currentPrice"),
    @Mapping(target = "user", source = "user"),
    @Mapping(target = "id", ignore = true),
    @Mapping(target = "documents", ignore = true),
public abstract void sourceToDestination(final "Type" request,
                                         final "Type" user,
                                         final @MappingTarget TargetA input);

And the TargetA class is as follows.

    @FieldDefaults(level = AccessLevel.PRIVATE)
    public class TargetA extends BlaBla {
        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "investment_loan_type_id")
        TypeB type_b_value;


Please check if in your Controller layer you have multiple methods mapped to the same endpoint (@Path).

This Question was asked in StackOverflow by mster3313 and Answered by Windir It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?