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.

Diagnose it: get the real failure out of Gradle

Gradle summarises failures aggressively, and the top-level message frequently describes a downstream symptom rather than the cause. Re-run the failing task with diagnostics before changing build logic.

Terminal
# the actual stack, plus what Gradle decided about the build
./gradlew <task> --stacktrace --info

# is a stale daemon or cache involved?
./gradlew --stop
./gradlew <task> --no-daemon --no-build-cache

# what does Gradle think the environment is?
./gradlew -version

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);

Configuration cache and CI

  • The configuration cache rejects build logic that reads mutable state at execution time, which is why enabling it surfaces errors an existing build never showed.
  • Run with --configuration-cache-problems=warn first to see the full list rather than failing on the first one.
  • A cached configuration keyed to a different environment is worse than none. Include the JDK version in your cache key.

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 MapStruct "No implementation was created for Mapper"?
There are 3 common causes: processor not declared, another processor failed first, and unmappable property with default policy. mapstruct-processor is not on annotationProcessor (Gradle) / annotationProcessorPaths (Maven), so no impl is generated.
How do I fix MapStruct "No implementation was created for Mapper"?
There are 3 fixes depending on which cause you have: declare the mapstruct processor, order lombok and mapstruct correctly, and resolve the unmapped property. Work through them in order, since the first is the most common.
What does MapStruct "No implementation was created for Mapper" actually mean?
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.
How do I stop MapStruct "No implementation was created for Mapper" happening again?
Declare mapstruct-processor in every module that defines mappers. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card