eclipse 错误:无法初始化模块 TreeWalker - 无法实例化 JUnitTestCase

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29136430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:30:04  来源:igfitidea点击:

Error: cannot initialize module TreeWalker - Unable to instantiate JUnitTestCase

javaeclipsemavencheckstyle

提问by Continuity8

After importing a maven project to Eclipse Luna the following error is displayed in a pop-up when saving after modifying a method:

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

cannot initialize module TreeWalker - Unable to instantiate JUnitTestCase

无法初始化模块 TreeWalker - 无法实例化 JUnitTestCase

JUnitTestCase is referring to a module in the checkstyle xml file:

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

<module name="JUnitTestCase"/>

I have the 'Checkstyle configuration plugin for M2Eclipse' and 'Checkstyle Plug-in 6.4.0' installed. The plugin definition for 'maven-checkstyle-plugin' in my pom file specifies version 2.10.

我安装了“M2Eclipse 的 Checkstyle 配置插件”和“Checkstyle 插件 6.4.0”。我的 pom 文件中 'maven-checkstyle-plugin' 的插件定义指定版本 2.10。

Note:I realise this is similar to some other questions with the same error (but a different module specified) however I am yet to find a satisfying solution. I believe that I could remove the module entry in the checkstyle config file but I require it to work as designed so that is not the preferable option.

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

回答by barfuin

JUnitTestCase was removed in Checkstyle 6.2(look under "Breaking backward compatibility"). So you should either downgrade to Checkstyle 6.1.1, or remove the module reference from your checkstyle.xml.

JUnitTestCase在 Checkstyle 6.2 中删除(查看“打破向后兼容性”)。因此,您应该降级到 Checkstyle 6.1.1,或者从checkstyle.xml 中删除模块引用。