checkstyle自定义检查错误无法示例化com.mycompany.checks.methodlimitcheck

ua4mk5z4  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(239)

我正在尝试使用checkstyle-8.38-all.jar基于https://checkstyle.org/writingchecks.html. 有人有这种定制支票的工作示例吗?我将mycompany-checkstyle-checks-1.0.jar和checkstyle-8.38-all.jar添加到java类路径中,但仍然不走运。
我总是犯这个错误

java -classpath mycompany-checkstyle-checks-1.0.jar;checkstyle-8.38-all.jar com.puppycrawl.tools.checkstyle.Main -c checkstyle.xml src/
com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - cannot initialize module com.mycompany.checks.MethodLimitCheck - Unable to instantiate com.mycompany.checks.MethodLimitCheck
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:482)
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:201)
        at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:404)
        at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:331)
        at com.puppycrawl.tools.checkstyle.Main.execute(Main.java:190)
        at com.puppycrawl.tools.checkstyle.Main.main(Main.java:125)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module com.mycompany.checks.MethodLimitCheck - Unable to instantiate com.mycompany.checks.MethodLimitCheck
        at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:125)
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:201)
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:477)
        ... 5 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate com.mycompany.checks.MethodLimitCheck
        at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createObject(PackageObjectFactory.java:370)
        at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:198)
        at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:116)
        ... 7 more
Caused by: java.lang.InstantiationException
        at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createObject(PackageObjectFactory.java:367)
        ... 9 more
Checkstyle ends with 1 errors.

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题