Encountering an unexpected language choice when using JPA Buddy to generate MapStruct interfaces can be a bit perplexing. Many users have found that even in a predominantly Java project, JPA Buddy defaults to creating these interfaces in Kotlin, without offering a clear language selection option within the ‘New -> Other (JPA Buddy icon): MapStruct Interface’ panel.

This can lead to a minor inconvenience, as developers then need to manually convert or adjust the generated files. Fortunately, a solution exists, though it requires a quick dive into your project’s configuration files.

The key to resolving this lies in modifying the .idea/jpa.xml file within your project’s root directory. This file contains project-specific settings for the JPA Buddy plugin. By changing the lastSelectedLanguage option from “Kotlin” to “Java”, you can instruct JPA Buddy to generate new MapStruct interfaces in Java moving forward.

Here’s the snippet you’ll need to locate and modify:

  <component name="JpaPluginProjectSettings">
    <option name="lastSelectedLanguage" value="Java" />
  </component>

After making this simple change, you should find that JPA Buddy correctly generates your MapStruct interfaces in Java, streamlining your development workflow and aligning with your project’s language preferences.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed