Aymen Kanzari
Aymen Kanzari

Reputation: 2013

throws noSuchMethodError in MapStruct

I have a boolean and an enum defined in my entity and my dto

@Entity
public class ConfigurationItemEntity {

    @Id
    private String externalId;

    private ConfigurationTypeEnum configurationType;

    private boolean active;

    public String getExternalId() {
       return externalId;
    }

    public void setExternalId(String externalId) {
       this.externalId = externalId;
    }

    public ConfigurationType getConfigurationType() {
       return configurationType;
    }

    public void setConfigurationType(ConfigurationType configurationType) {
       this.configurationType = configurationType;
    }

    public boolean isActive() {
       return active;
    }

    public void setActive(boolean active) {
       this.active = active;
    }

}

public class ConfigurationItem {

    private String externalId;

    private ConfigurationTypeEnum configurationType;

    private boolean active;
}

I wan to map the dto to entity

@Mapper(componentModel = "spring")
public interface ConfigurationItemMapper {

    ConfigurationItemEntity configItemDomainToConfigItemEntity(ConfigurationItem configurationItem);

}

but i get this error

java.lang.NoSuchMethodError: com.xx.mapper.ConfigurationItemMapper.configItemDomainToConfigItemEntity(Lcom/xx/uc/health/administration/ConfigurationItem;)Lcom/xx/entities/ConfigurationItemEntity;

Upvotes: 3

Views: 3851

Answers (2)

tbotalla
tbotalla

Reputation: 125

In my case missing the implements Serializable was the problem. Hope it helps someone

Upvotes: 0

vcmkrtchyan
vcmkrtchyan

Reputation: 2626

According to MapStruct documentation

MapStruct is an annotation processor which is plugged into the Java compiler and can be used in command-line builds (Maven, Gradle etc.) as well as from within your preferred IDE.

It works during the compile phase of maven lifecycle, so make sure that you run mvn clean compile before using it. You may validate the generated mapper by looking at target/generated-sources (This is where they get generated by default)

Upvotes: 3

Related Questions