I was having that weird error when I was working with mapstruct, turn out that the default java version for mapstruct is java 6. Since our project was in java 11 I was getting the error “Constructor XXX in enum XXX cannot be applied to given types”.
My starting config was :
<dependencies><dependency><groupId>org.mapstruct</groupId><artifactId>mapstruct</artifactId><version>${org.mapstruct.version}</version></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version><configuration><release>${java.version}</release><source>1.6</source> <!-- or higher, depending on your project --><target>1.6</target> <!-- or higher, depending on your project --><annotationProcessorPaths><path><groupId>org.mapstruct</groupId><artifactId>mapstruct-processor</artifactId><version>${org.mapstruct.version}</version></path></annotationProcessorPaths></configuration></plugin></plugins></build>
After some research, turn out there a mapstruct version for java 8 and more. You can use the following maven to configure mapstruct for java 8 or higher :
<dependencies><dependency><groupId>org.mapstruct</groupId><!-- use mapstruct-jdk8 for Java 8 or higher --><artifactId>mapstruct-jdk8</artifactId><version>${org.mapstruct.version}</version></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version><configuration><release>${java.version}</release><!-- or higher, depending on your project --><source>1.11</source><target>1.11</target><annotationProcessorPaths><path><groupId>org.mapstruct</groupId><artifactId>mapstruct-processor</artifactId><version>${org.mapstruct.version}</version></path></annotationProcessorPaths></configuration></plugin></plugins></build>
Let me know if you had that problem and if this helped you.
Recent Comments