Error: cannot initialize module TreeWalker - Unable to instantiate JUnitTestCase

Error: cannot initialize module TreeWalker - Unable to instantiate JUnitTestCase

将maven项目导入Eclipse Luna后,修改方法后保存时弹出如下错误:

cannot initialize module TreeWalker - Unable to instantiate JUnitTestCase

JUnitTestCase 指的是 checkstyle xml 文件中的一个模块:

<module name="JUnitTestCase"/>

我安装了 'Checkstyle configuration plugin for M2Eclipse' 和 'Checkstyle Plug-in 6.4.0'。我的 pom 文件中 'maven-checkstyle-plugin' 的插件定义指定版本 2.10.

注意:我意识到这与其他一些具有相同错误的问题类似(但指定了不同的模块)但是我还没有找到令人满意的解决方案。我相信我可以删除 checkstyle 配置文件中的模块条目,但我要求它按设计工作,所以这不是更好的选择。

JUnitTestCase 是 removed in Checkstyle 6.2(查看 "Breaking backward compatibility")。因此,您应该降级到 Checkstyle 6.1.1,或者从 checkstyle.xml.

中删除模块引用