-
Notifications
You must be signed in to change notification settings - Fork 40
Description
I'm starting afresh with MapStruct version 1.0.0.Final and receive the following error when I attempt to execute the codebase,
java.lang.RuntimeException: java.lang.ClassNotFoundException: Cannot find implementation
My Maven POM has the following added already,
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<configuration>
<defaultOutputDirectory>
${project.build.directory}/generated-sources/annotations
</defaultOutputDirectory>
<processors>
<processor>org.mapstruct.ap.MappingProcessor</processor>
</processors>
<options>
<mapstruct.suppressGeneratorTimestamp>true</mapstruct.suppressGeneratorTimestamp>
<!-- <mapstruct.defaultComponentModel>cdi</mapstruct.defaultComponentModel> -->
</options>
</configuration>
<executions>
<execution>
<id>process</id>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
</dependencies>
</plugin>
Please note that I've modified the defaultOutputDirectory to be ${project.build.directory}/generated-sources/annotations (added an extra 'annotations`). If not adding that suffix, I am generating two sets of implementation, one at the generated-sources level and another at ..generated-sources/annotations level and that causes duplicate implementation exists error like below during compilation of the project,
error: duplicate class: a.g.x.h.t.mappers.DMapperImpl
The error is occurring when invoking the Mapper class using the below even though I could very well see the Implementations of the Mapper classes at ...target../generated-sources/annotations directory,
DMapper.INSTANCE.sourceToDestination(source);
- On a general note, I'm trying to map fields from a bean which is located at say from a package, a.b.c.Bean to another package x.y.z.Bean with about 100s of elements within it (the destination might have couple elements removed, added and renamed fields) but, I couldn't see any straight forward way of achieving this
- There isn't good examples out there to showcase how to achieve this and hence it was really hard to get up and running with this. May be the documentation surrounding the usage could be improvised to help out others
- In a Mapper which uses other Mappers and say the 4th occurrence uses one of the other Mapper but, the 3rd occurrence field also uses, this plugin is not intelligent enough to scan the used Mappers but, instead it is requiring to specify the other Mapper in the current file
- Another thing about the way to identify any issues, I've already installed the MapStruct Eclipse plug-in but, it not helping out with anything and so, I've to do
mvn compileon my project to identify the errors/warnings