One of the big advantages of MapStruct is the early feedback on problems with the mapping configuration. To fully leverage this in your IDE, make sure the annotation processor runs with each compilation.
If your work with a Maven project, then make sure you have the latest version of the m2e-apt plugin installed, which picks up and applies the annotation processor settings automatically.
For best results, add the following to the
<!-- automatically run annotation processors within the incremental compilation -->
For Eclipse, we are also working on a Plugin that adds Code Completion (e.g. for property names) and Quick Fixes for common use cases:
Completion for Properties and Enum Constants
Quick Fix to Ignore an Unmapped Property
Drag the following icon into your running Eclipse workspace:
Alternatively, you can obtain the MapStruct Eclipse Plugin from the Eclipse Marketplace.
For more information and for installing the latest Snapshot version, visit the plugins GitHub project.
Depending on how you configured the annotation processor in your Maven or Gradle project, IntelliJ may or may not pick it up automatically. You might need to make sure of it yourself in the project configuration.
For example, if you use the way of Maven configuration that is proposed in our documentation using
annotationProcessorPaths in the maven-compiler-plugin, then you need to configure IntelliJ manually until the feature request IDEA-150621 is implemented. An alternative is to add the
mapstruct-processor as a project dependency with
<optional>true</optional> in your
pom.xml, which should then be picked up automatically again.
As for the editing support of MapStruct mappers, there is an open feature request in the IntelliJ backlog: MapStruct support. Perhaps some additional votes help there. Or better yet, if you want to start with it, we’d probably join you in your efforts.
If you use a Maven project, then there’s nothing more to do. NetBeans uses Maven to compile your sources, which includes the invocation of the annotation processor.
There are no plans of special editing support for MapStruct mappers in NetBeans that we know of, yet. But we’d love to see one!