Skip to content
Latchkey

MapStruct "No implementation was created for Mapper" - Fix in CI

MapStruct generates a *MapperImpl during annotation processing. If the processor is not on the annotation-processing path, or a mapping is unresolvable, no implementation is generated and Mappers.getMapper(...) or injection of the mapper fails at compile or runtime.

What this error means

Compilation reports No implementation was created for FooMapper due to having a problem in the erroneous element, or runtime fails with ClassNotFoundException: com.example.FooMapperImpl / NoSuchBeanDefinitionException for the mapper.

java
error: No implementation was created for OrderMapper due to having a problem
in the erroneous element jakarta.persistence ... Hint: this often means that
some other annotation processor failed first, or MapStruct is not registered.

Common causes

Processor not declared

mapstruct-processor is not on annotationProcessor (Gradle) / annotationProcessorPaths (Maven), so no impl is generated.

Another processor failed first

Lombok or a different processor errored, aborting the round so MapStruct never produced its output.

Unmappable property with default policy

An unmapped target property under a strict unmappedTargetPolicy = ERROR fails generation.

How to fix it

Declare the MapStruct processor

Add the processor on the annotation-processing path.

gradle
dependencies {
  implementation 'org.mapstruct:mapstruct:1.6.0'
  annotationProcessor 'org.mapstruct:mapstruct-processor:1.6.0'
}

Order Lombok and MapStruct correctly

When using both, add the lombok-mapstruct binding so Lombok output is visible to MapStruct.

gradle
dependencies {
  annotationProcessor 'org.projectlombok:lombok:1.18.34'
  annotationProcessor 'org.projectlombok:lombok-mapstruct-binding:0.2.0'
  annotationProcessor 'org.mapstruct:mapstruct-processor:1.6.0'
}

Resolve the unmapped property

Map or ignore the property the error names so generation completes.

Java
@Mapping(target = "id", ignore = true)
OrderDto toDto(Order order);

How to prevent it

  • Declare mapstruct-processor in every module that defines mappers.
  • Add lombok-mapstruct-binding when both processors are present.
  • Keep mappings exhaustive or explicitly ignore unmapped targets.

Frequently asked questions

What causes ""No implementation was created for Mapper""?
mapstruct-processor is not on annotationProcessor (Gradle) / annotationProcessorPaths (Maven), so no impl is generated.
How do I fix "No implementation was created for Mapper"?
Add the processor on the annotation-processing path.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card