升级到 VS Code 1.93.1(2024 年 10 月)后,VS Code 开始无法为我的 Java 应用程序生成 MapStruct 映射器,并出现以下错误:
Error occured while building workspace. Details:
message: No implementation was created for xxxMapper due to having a problem in the erroneous element java.util.ArrayList. Hint: this often means that some other annotation processor was supposed to process the erroneous element. You can also enable MapStruct verbose mode by setting -Amapstruct.verbose=true as a compilation argument.
我将 Maven 与 Lombok 1.18.30 和 MapStruct 1.5.5.Final 一起使用。命令行编译工作正常,仅在使用 VS Code IDE 构建时才会出现问题。
下面是我的mavenannotationProcessorPaths配置。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>${lombok.mapstruct.binding.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
该问题并非来自 VS Code 更新本身,而是来自 Red Hat 插件更新的 Java(TM) 语言支持,版本 1.36。
将 Java(TM) 插件的语言支持回滚到以前的版本 (1.35.1) 可以解决该问题。
我已在这里报告了该问题:https://github.com/redhat-developer/vscode-java/issues/3843