IDEA 运行单元测试报错 @{argLine}

sentinel是今年阿里开源的高可用防护的流量管理框架

git地址:https://github.com/alibaba/Sentinel

wiki:https://github.com/alibaba/Sentinel/wiki

FAQ:https://github.com/alibaba/Sentinel/wiki/FAQ

--------------------------------------------------------------------------------------------------------------------------------------------------------

工程里有很多单元测试,在IDEA里运行时报错:

����: �Ҳ������޷��������� @{argLine}

错误信息有乱码,VM参数加上-Dfile.encoding=UTF-8,再次运行:

错误: 找不到或无法加载主类 @{argLine}

解决方法:File->Settings->Build,Execution,Deployment->Build Tools->Maven->Running Tests 去掉argLine的勾选

--------------------------------------------------------------------------------------------------------------------------------------------------------

ctrl+shift+F全局搜索@{argLine},发现在sentinel-parent父工程的pom.xml里,使用了一个maven插件

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <!-- CircleCI build workaround -->
        <argLine>@{argLine} -Xms1024m -Xmx2048m</argLine>         
        <useSystemClassLoader>false</useSystemClassLoader>
    </configuration>
</plugin>

参考maven官方文档:http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#late-property-evaluation

allows late replacement of properties when the plugin is executed, so properties that have been modified by other plugins will be picked up correctly.

该占位符能让后面的插件在执行时正确的替换属性。

sentinel官方团队也在钉钉群给了说明:

这是 CI 生成测试覆盖率报告的时候自动装填用的,本地可以去掉。

原文地址:https://www.cnblogs.com/cdfive2018/p/10167188.html