Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation error: duplicate class with MapStruct in IntelliJ IDEA 2019.1

I am using Mapstruct for mapping between different Java Beans, but after installing the latest IntelliJ update, Compilation is getting failed with error:

Compilation error: duplicate class

Here are the version details of IntelliJ

IntelliJ IDEA 2019.1 (Ultimate Edition)
Build #IU-191.6183.87, built on March 27, 2019
JRE: 1.8.0_202-release-1483-b39 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.3

Compilation Error :

Error:(14, 8) java: duplicate class: com.company.mapper.GMapperImpl
like image 930
Neeraj Jain Avatar asked Mar 29 '19 10:03

Neeraj Jain


People also ask

Does mapstruct work with IntelliJ?

I am very happy to announce the first version of the MapStruct IntelliJ IDEA plugin. Now we have official support for 2 IDEs, Eclipse being the first IDE for which we had support from earlier (plugin here ). With the power of IntelliJ you now get completions in @Mapping and @ValueMapping annotations (also for nested mappings ;)).

What's new in the mapstruct plugin?

With this plugin we are bringing first class support for MapStruct within IntelliJ and addressing long lasting requests from users for the support (such as mapstruct#520 and IDEABKL-7174 ). Some of the new features:

How do I import a cloned mapstruct file into idea?

After you’ve cloned you can import it by selecting “File -> Import Module …” and then selecting the top level aggregator pom.xml file located in the root folder. IDEA then will load MapStruct, resolve all dependencies and compile the source. You might face an error on IDEAs Message tab saying

How do I rebuild a mapstruct file?

If so, open the preferences window, navigate to Compiler -> Annotation processor and untick checkbox “Enable annotation processing” at “Annotation profile for mapstruct-integrationtest”. You should now be able to rebuild MapStruct.


1 Answers

I was facing similar issue for my classes and it got resolved by performing maven clean from inside intellij by clicking on clean lifecycle phase on maven project where this error is coming and then build the project again from intellij.

enter image description here

like image 138
Anshul Singhal Avatar answered Oct 13 '22 17:10

Anshul Singhal