在使用 maven-surefire-plugin 时,实现这一点的方法之一是使用延迟属性求值的语法:
<!--
Source - https://stackoverflow.com/a/23605812
Posted by Jacek Laskowski, modified by community. See post 'Timeline' for change history
Retrieved 2025-12-28, License - CC BY-SA 4.0
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -your -extra -arguments</argLine>
</configuration>
</plugin>
注意@{argLine}添加到-your -extra -arguments.
例如:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} --add-opens java.base/java.net=ALL-UNNAMED</argLine>
</configuration>
</plugin>
若仍没生成jacoco 覆盖率报告,考虑设置默认激活的 profile,使用 <activeByDefault>true</activeByDefault> 配置:
<!-- 配置 profiles -->
<profiles>
<!-- 默认激活的 profile -->
<profile>
<!-- profile 唯一标识 -->
<id>default-profile</id>
<!-- 激活配置:设置为默认激活 -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
代码调试记录,希望有所帮助。
1446

被折叠的 条评论
为什么被折叠?



