why is causing Error: java: Annotation processor 'org.mapstruct.ap.MappingProcessor' not found?
I'm using IntelliJ 13.0.2 on OSX 10.9.5, using java 1.8. I get this error when trying to run or debug a unit test inside IntelliJ. When I run compile or test via maven at the command line, it runs fine.
I've gone into File->Other Settings->Default Settings->Compiler->Annotation Processors and unchecked Enable annotation processing. I've also tried it with Enable annotation processing checked, and left the defaults selected, and still get the error.
We're running our tests with
@RunWith(MockitoJUnitRunner.class)
and the Annotation processor it can't find is org.mapstruct.ap.MappingProcessor. I don't know where it's getting that from, it's not in our imports. Maybe a dependency from Mockito?
Please sign in to leave a comment.
I have the same problem with Intellij 14.1.3. Building with Maven works fine, but building with Intellij fails. I've also tried enabling/disabling.... the Mapstruct annotation processor, but all the combinations have failed so far.
Any idea ?
The MappingProcessor is in org.mapstruct:mapstruct-processor which is declared as a dependency of the maven-processor-plugin plugin. While IntelliJ manages to find the need to run the processor it does not find the dependency in the plugin declaration.
My workaround is to create a profile specific to IntelliJ and mapstruct-processor as dependency here:
I've added directly the dependency but with provided scope :
Works fine now.
This feels like a dumb question, but do you mean you create this profile within your project's pom file?
Yes exactly and from IntelliJ's maven projects window you can activate this profile.
Antonio's solution of using a provided scope also work but I feel more interesting to have a profile so there will be no disturbance for plain mvn build.
What mapstruct.version do you use?
Also, how do you activate a profile? I see the Maven Projects view, and I can open the profiles and check the IntelliJ Workaround one. But how do I activate that only for running tests?
Sorry I'm kind of a maven newb as well.