Reputation: 111
Im trying to use Mapstruct in my application. I included the dependency and see that it has been successfully downloaded into my project, but the @Mapper annotation is not being recognized.
My relevant dependencies are as follows
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.5.Final</version>
</dependency>
When this alone didn't work, I added it to the annotation processorPaths in maven-compiler-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.5.5.Final</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Some sources said order of the paths might matter, swapping them around didn't help. I also tried added the following path to annotationProcessorPaths:
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
This also did not work. I also tried adding mapstruct-processor as a dependency directly and that didn't help either.
I am using Intellij and "Enable annotation processing" is checked. Any ideas whats happening here?
Using Java 17 by the way.
Upvotes: 0
Views: 639
Reputation: 1
I had the same problem.
This was the dependency I fixed this problem with
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.6.0.Beta1</version>
</dependency>
Regarding the Plugin, I used this
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.6.0.Beta1</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Upvotes: 0