Search code examples
intellij-ideamapstructjava-17

Mapstruct Java 17 gives error in test cases when running via IntelliJ


Recently upgraded my code to java 17. Earlier I was using MapStruct 1.3.1 with Java 11.

So, let me tell/show you the three scenarios.


SCENARIO 1

So now after java 17 update when I run my test case (say MyTestMethod) with the run button in IntelliJ

enter image description here

It throws this error -

java: Supported source version 'RELEASE_6' from annotation processor 'org.mapstruct.ap.MappingProcessor' less than -source '17'


SCENARIO 2

But if I run the same test case with this command -

mvn test -Dtest="MyTestClass#MyTestMethod"

Its a SUCCESS


SCENARIO 3

However If I change the version of MapStruct to 1.5.5.final SCENARIO 1 starts working correctly.


My questions now -

  1. Do I need to upgrade to 1.5.5.final, if so is there anything I should change in my code too to adhere to java 17 - mapstruct compatibility?
  2. Why SCENARIO 1 starts working when I change the version from 1.3.1.final to 1.5.5.final as mentioned in SCENARIO 3 ?

Solution

  • I was able to solve this in intellij by adding this in compiler settings

    -Djps.track.ap.dependencies=false like shown in the picture

    enter image description here