Search code examples
javaspring-bootintellij-ideapreviewmapstruct

Java preview feature in Mapstruct


I am facing issues with mapstruct while running the code in Intellij

java: classfile for /C:/Users/workspace/ng-service/target/classes/org/converter/RepresentationConverterImpl.class 
uses preview features of Java SE 15. (use --enable-preview to allow loading of classfiles which contain preview features)

Because of the error above I am not able to run the app on Intellij's latest version 2022. I tried adding --enable-preview in pom.xml as well as in Intellij compiler but still no luck.

It is working fine with Intellij-2021. The person who uses preview features of java 15 left the organization and now all are suffering to use old intellij version.


      <java.version>15</java.version>
      <mapstruct.version>1.5.2.Final</mapstruct.version>
    
      <configuration>
          <includes>
              <include>Test.java</include>
          </includes>
          <skipTests>false</skipTests>
          <argLine>@{argLine} --enable-preview</argLine>
      </configuration>
    
    
             <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                        <release>${java.version}</release>
                        <compilerArgs>--enable-preview</compilerArgs>
                        <annotationProcessorPaths>
                            <path>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok-mapstruct-binding</artifactId>
                                <version>0.2.0</version>
                            </path>
                            <path>
                                <groupId>org.mapstruct</groupId>
                                <artifactId>mapstruct-processor</artifactId>
                                <version>${mapstruct.version}</version>
                            </path>
                            <path>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>${lombok.version}</version>
                            </path>
                        </annotationProcessorPaths>
                    </configuration>
                </plugin>

I tried following most of resources on web to fix the issue but not finding any working solution.

thank you


Solution

  • This issue is resolved by java in open JDK 17. Just tested the code with having a preview feature and with the latest IntelliJ 2022 and it's working as expected.