如何解决IntelliJ中cucumberOutput相关的Maven配置错误
问题原因
maven-cucumber-reporting从4.0.0版本开始,废弃了顶级<cucumberOutput>配置标签,改为集合类的配置结构。Eclipse的POM校验逻辑宽松,对废弃标签容错率高,所以可以正常运行;IntelliJ的POM schema校验规则更严格,因此会抛出Element cucumberOutput is not allowed here的错误。- 补充注意:原配置的路径还存在语法问题,
${project.build.directory}后缺少斜杠,会拼接成错误路径targetcucumber/cucumber.json。
解决方案
方案1:适配5.6.0版本修改配置(推荐)
将<configuration>块中的<cucumberOutput>标签替换为5.6.0版本支持的<jsonFiles>集合结构,同时修正路径的斜杠问题,修改后的完整配置如下:
<plugin> <groupId>net.masterthought</groupId> <artifactId>maven-cucumber-reporting</artifactId> <version>5.6.0</version> <executions> <execution> <id>execution</id> <phase>verify</phase> <goals> <goal>generate</goal> </goals> <configuration> <projectName>Automation</projectName> <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory> <jsonFiles> <jsonFile>${project.build.directory}/cucumber/cucumber.json</jsonFile> </jsonFiles> </configuration> </execution> </executions> </plugin>
修改完成后右键pom.xml,选择「Maven - Reload project」刷新Maven缓存即可消除报错。
方案2:降级插件版本
如果不想调整配置结构,可将插件版本降级到3.20.0,该版本仍支持<cucumberOutput>标签,仅需修改版本号即可:
<version>3.20.0</version>
修改后同样刷新Maven缓存即可。
内容的提问来源于stack exchange,提问作者Hari
相关产品推荐
相关产品推荐

