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

ect*_*n84 7 checkstyle maven

我配置了maven-checkstyle-plugin(v2.5)和maven-eclipse-plugin(v2.8).

一切都按预期工作但我一介绍,

模块名称="SuppressWarningsHolder" 和/或 模块名称="SuppressWarningsFilter"

到我的checkstyle-config.xml,我开始在构建项目时遇到问题.

这是我得到的:

[ERROR] BUILD ERROR
1>  [INFO] ------------------------------------------------------------------------
1>  [INFO] Failed during checkstyle configuration
1>  
1>EXEC : Embedded error : cannot initialize module TreeWalker - Unable to instantiate SuppressWarningsHolder
1>  Unable to instantiate SuppressWarningsHolderCheck
Run Code Online (Sandbox Code Playgroud)

如果我删除SuppressWarningsHolderCheck,我会得到相同的SuppressWarningsFilter错误.

有任何想法吗?

谢谢

bar*_*uin 8

看来你有两个问题:

  • 您使用的是maven-checkstyle-plugin v2.5,它基于Checkstyle 5.0.在Checkstyle 5.0中,SuppressWarningsHolderCheck和SuppressWarningsFilter尚未存在,因为它们是在5.7中引入的.所以你必须先升级你的maven-checkstyle-plugin.
  • SuppressWarningsFilter必须直接下配置Checker,不能下TreeWalker.尽管文档存在,但文档并没有使这一部分非常明确.请注意,SuppressWarnings 持有人 确实TreeWalker.

如果你做这两件事,那么东西应该有希望开始工作.