IntelliJ中pom.xml不允许使用annotationProcessorPaths问题求助
解决IntelliJ标注Maven中annotationProcessorPaths不允许的问题
出现这个报错的核心原因是你使用的maven-compiler-plugin版本过低,annotationProcessorPaths配置项是在3.5及以上版本的插件中才被引入的,旧版本不支持该配置,所以IntelliJ会提示此处不允许。
解决步骤如下:
指定maven-compiler-plugin的兼容版本
在插件配置中添加version标签,指定3.8.1及以上的稳定版本,修改后的完整配置:<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>11</source> <target>11</target> <annotationProcessorPaths> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>1.4.2.Final</version> </path> </annotationProcessorPaths> </configuration> </plugin> </plugins> </build>补充MapStruct核心依赖
别忘了在dependencies节点中添加MapStruct的核心依赖,否则编译时可能找不到相关类:<dependencies> <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct</artifactId> <version>1.4.2.Final</version> </dependency> </dependencies>刷新Maven并清除IntelliJ缓存
- 点击右侧Maven面板的刷新按钮,重新导入项目依赖
- 如果还是报错,执行
File -> Invalidate Caches...,选择Invalidate and Restart重启IDE,清除缓存后即可正常识别配置
内容的提问来源于stack exchange,提问作者Oladejo Olajide
相关产品推荐
相关产品推荐

