【问题标题】:Java preview feature in MapstructMapstruct 中的 Java 预览功能
【发布时间】:2022-11-10 19:52:39
【问题描述】:

在 Intellij 中运行代码时,我遇到了 mapstruct 的问题

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)

由于上述错误,我无法在 Intellij 的最新版本 2022 上运行该应用程序。我尝试在 pom.xml 以及 Intellij 编译器中添加 --enable-preview 但仍然没有运气。

它在 Intellij-2021 上运行良好。使用 java 15 预览功能的人离开了组织,现在所有人都在使用旧的 intellij 版本。


      <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>

我尝试关注网络上的大部分资源来解决问题,但没有找到任何可行的解决方案。

谢谢你

【问题讨论】:

标签: java spring-boot intellij-idea preview mapstruct


【解决方案1】:

此问题已由开放 JDK 17 中的 java 解决。刚刚测试了具有预览功能和最新 IntelliJ 2022 的代码,它按预期工作。

【讨论】:

    猜你喜欢
    • 2019-08-15
    • 2020-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    相关资源
    最近更新 更多